audible-api-ts 0.1.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/LICENSE +21 -0
- package/README.md +71 -0
- package/dist/client.d.ts +43 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4261 -0
- package/dist/library.d.ts +26 -0
- package/dist/library.d.ts.map +1 -0
- package/dist/locales.d.ts +4 -0
- package/dist/locales.d.ts.map +1 -0
- package/dist/schemas.d.ts +116 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/signing.d.ts +8 -0
- package/dist/signing.d.ts.map +1 -0
- package/dist/types.d.ts +49 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils.d.ts +5 -0
- package/dist/utils.d.ts.map +1 -0
- package/package.json +58 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { AudibleCredentials, AudibleItem } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Fetch the user's entire Audible library with automatic pagination.
|
|
4
|
+
*
|
|
5
|
+
* @returns All library items and the (potentially refreshed) credentials
|
|
6
|
+
*/
|
|
7
|
+
export declare const fetchLibrary: (credentials: AudibleCredentials) => Promise<{
|
|
8
|
+
items: AudibleItem[];
|
|
9
|
+
credentials: AudibleCredentials;
|
|
10
|
+
}>;
|
|
11
|
+
/**
|
|
12
|
+
* Fetch the user's entire Audible wishlist with automatic pagination.
|
|
13
|
+
*
|
|
14
|
+
* @returns All wishlist items and the (potentially refreshed) credentials
|
|
15
|
+
*/
|
|
16
|
+
export declare const fetchWishlist: (credentials: AudibleCredentials) => Promise<{
|
|
17
|
+
items: AudibleItem[];
|
|
18
|
+
credentials: AudibleCredentials;
|
|
19
|
+
}>;
|
|
20
|
+
/**
|
|
21
|
+
* Verify that credentials are valid by making a minimal API call.
|
|
22
|
+
*
|
|
23
|
+
* @throws If credentials are invalid or expired
|
|
24
|
+
*/
|
|
25
|
+
export declare const verifyConnection: (credentials: AudibleCredentials) => Promise<void>;
|
|
26
|
+
//# sourceMappingURL=library.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"library.d.ts","sourceRoot":"","sources":["../src/library.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAyFjE;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAU,aAAa,kBAAkB;;;EACzB,CAAA;AAEzC;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAU,aAAa,kBAAkB;;;EACzB,CAAA;AAE1C;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAAU,aAAa,kBAAkB,kBAMrE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locales.d.ts","sourceRoot":"","sources":["../src/locales.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE7D,yEAAyE;AACzE,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,aAAa,EAAE,YAAY,CAWtD,CAAA"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** Zod schema for parsing raw Audible API item responses */
|
|
3
|
+
export declare const audibleRawItemSchema: z.ZodObject<{
|
|
4
|
+
asin: z.ZodString;
|
|
5
|
+
title: z.ZodString;
|
|
6
|
+
authors: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
7
|
+
name: z.ZodString;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
name: string;
|
|
10
|
+
}, {
|
|
11
|
+
name: string;
|
|
12
|
+
}>, "many">>;
|
|
13
|
+
narrators: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
14
|
+
name: z.ZodString;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
name: string;
|
|
17
|
+
}, {
|
|
18
|
+
name: string;
|
|
19
|
+
}>, "many">>;
|
|
20
|
+
runtime_length_min: z.ZodDefault<z.ZodNumber>;
|
|
21
|
+
publisher_name: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodString>>, string | undefined, string | null | undefined>;
|
|
22
|
+
language: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodString>>, string | undefined, string | null | undefined>;
|
|
23
|
+
release_date: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodString>>, string | undefined, string | null | undefined>;
|
|
24
|
+
product_images: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>>, Record<string, string> | undefined, Record<string, string> | null | undefined>;
|
|
25
|
+
series: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
26
|
+
asin: z.ZodString;
|
|
27
|
+
title: z.ZodString;
|
|
28
|
+
sequence: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodString>>, string | undefined, string | null | undefined>;
|
|
29
|
+
}, "strip", z.ZodTypeAny, {
|
|
30
|
+
asin: string;
|
|
31
|
+
title: string;
|
|
32
|
+
sequence?: string | undefined;
|
|
33
|
+
}, {
|
|
34
|
+
asin: string;
|
|
35
|
+
title: string;
|
|
36
|
+
sequence?: string | null | undefined;
|
|
37
|
+
}>, "many">>>, {
|
|
38
|
+
asin: string;
|
|
39
|
+
title: string;
|
|
40
|
+
sequence?: string | undefined;
|
|
41
|
+
}[], {
|
|
42
|
+
asin: string;
|
|
43
|
+
title: string;
|
|
44
|
+
sequence?: string | null | undefined;
|
|
45
|
+
}[] | null | undefined>;
|
|
46
|
+
listening_status: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
47
|
+
is_finished: z.ZodOptional<z.ZodBoolean>;
|
|
48
|
+
percent_complete: z.ZodOptional<z.ZodNumber>;
|
|
49
|
+
finished_at_timestamp: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
50
|
+
}, "strip", z.ZodTypeAny, {
|
|
51
|
+
is_finished?: boolean | undefined;
|
|
52
|
+
percent_complete?: number | undefined;
|
|
53
|
+
finished_at_timestamp?: string | null | undefined;
|
|
54
|
+
}, {
|
|
55
|
+
is_finished?: boolean | undefined;
|
|
56
|
+
percent_complete?: number | undefined;
|
|
57
|
+
finished_at_timestamp?: string | null | undefined;
|
|
58
|
+
}>>>, {
|
|
59
|
+
is_finished?: boolean | undefined;
|
|
60
|
+
percent_complete?: number | undefined;
|
|
61
|
+
finished_at_timestamp?: string | null | undefined;
|
|
62
|
+
} | undefined, {
|
|
63
|
+
is_finished?: boolean | undefined;
|
|
64
|
+
percent_complete?: number | undefined;
|
|
65
|
+
finished_at_timestamp?: string | null | undefined;
|
|
66
|
+
} | null | undefined>;
|
|
67
|
+
}, "strip", z.ZodTypeAny, {
|
|
68
|
+
asin: string;
|
|
69
|
+
title: string;
|
|
70
|
+
authors: {
|
|
71
|
+
name: string;
|
|
72
|
+
}[];
|
|
73
|
+
narrators: {
|
|
74
|
+
name: string;
|
|
75
|
+
}[];
|
|
76
|
+
runtime_length_min: number;
|
|
77
|
+
series: {
|
|
78
|
+
asin: string;
|
|
79
|
+
title: string;
|
|
80
|
+
sequence?: string | undefined;
|
|
81
|
+
}[];
|
|
82
|
+
publisher_name?: string | undefined;
|
|
83
|
+
language?: string | undefined;
|
|
84
|
+
release_date?: string | undefined;
|
|
85
|
+
product_images?: Record<string, string> | undefined;
|
|
86
|
+
listening_status?: {
|
|
87
|
+
is_finished?: boolean | undefined;
|
|
88
|
+
percent_complete?: number | undefined;
|
|
89
|
+
finished_at_timestamp?: string | null | undefined;
|
|
90
|
+
} | undefined;
|
|
91
|
+
}, {
|
|
92
|
+
asin: string;
|
|
93
|
+
title: string;
|
|
94
|
+
authors?: {
|
|
95
|
+
name: string;
|
|
96
|
+
}[] | undefined;
|
|
97
|
+
narrators?: {
|
|
98
|
+
name: string;
|
|
99
|
+
}[] | undefined;
|
|
100
|
+
runtime_length_min?: number | undefined;
|
|
101
|
+
publisher_name?: string | null | undefined;
|
|
102
|
+
language?: string | null | undefined;
|
|
103
|
+
release_date?: string | null | undefined;
|
|
104
|
+
product_images?: Record<string, string> | null | undefined;
|
|
105
|
+
series?: {
|
|
106
|
+
asin: string;
|
|
107
|
+
title: string;
|
|
108
|
+
sequence?: string | null | undefined;
|
|
109
|
+
}[] | null | undefined;
|
|
110
|
+
listening_status?: {
|
|
111
|
+
is_finished?: boolean | undefined;
|
|
112
|
+
percent_complete?: number | undefined;
|
|
113
|
+
finished_at_timestamp?: string | null | undefined;
|
|
114
|
+
} | null | undefined;
|
|
115
|
+
}>;
|
|
116
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,4DAA4D;AAC5D,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2C/B,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AudibleCredentials } from './types.js';
|
|
2
|
+
/** Sign an Audible API request using RSA SHA256 with the device private key */
|
|
3
|
+
export declare const signRequest: (method: string, path: string, body: string, credentials: AudibleCredentials) => {
|
|
4
|
+
'x-adp-token': string;
|
|
5
|
+
'x-adp-alg': string;
|
|
6
|
+
'x-adp-signature': string;
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=signing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signing.d.ts","sourceRoot":"","sources":["../src/signing.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAEpD,+EAA+E;AAC/E,eAAO,MAAM,WAAW,GACtB,QAAQ,MAAM,EACd,MAAM,MAAM,EACZ,MAAM,MAAM,EACZ,aAAa,kBAAkB;;;;CAchC,CAAA"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/** Supported Audible marketplace locales */
|
|
2
|
+
export type AudibleLocale = 'fr' | 'com' | 'co.uk' | 'de' | 'it' | 'es' | 'ca' | 'com.au' | 'in' | 'co.jp';
|
|
3
|
+
/** Marketplace configuration for a given locale */
|
|
4
|
+
export type LocaleConfig = {
|
|
5
|
+
domain: string;
|
|
6
|
+
marketplaceId: string;
|
|
7
|
+
countryCode: string;
|
|
8
|
+
};
|
|
9
|
+
/** Credentials obtained after device registration */
|
|
10
|
+
export type AudibleCredentials = {
|
|
11
|
+
accessToken: string;
|
|
12
|
+
refreshToken: string;
|
|
13
|
+
adpToken: string;
|
|
14
|
+
devicePrivateKey: string;
|
|
15
|
+
serial: string;
|
|
16
|
+
locale: AudibleLocale;
|
|
17
|
+
expiresAt: Date;
|
|
18
|
+
};
|
|
19
|
+
/** An audiobook item from Audible's catalog */
|
|
20
|
+
export type AudibleItem = {
|
|
21
|
+
asin: string;
|
|
22
|
+
title: string;
|
|
23
|
+
authors: string[];
|
|
24
|
+
narrators: string[];
|
|
25
|
+
durationMinutes: number;
|
|
26
|
+
publisher?: string;
|
|
27
|
+
language?: string;
|
|
28
|
+
releaseDate?: Date;
|
|
29
|
+
coverUrl?: string;
|
|
30
|
+
series?: {
|
|
31
|
+
name: string;
|
|
32
|
+
position?: number;
|
|
33
|
+
};
|
|
34
|
+
finishedAt?: Date;
|
|
35
|
+
};
|
|
36
|
+
/** PKCE auth session — returned by generateLoginUrl, passed back to registerDevice */
|
|
37
|
+
export type AuthSession = {
|
|
38
|
+
codeVerifier: string;
|
|
39
|
+
serial: string;
|
|
40
|
+
locale: AudibleLocale;
|
|
41
|
+
createdAt: Date;
|
|
42
|
+
};
|
|
43
|
+
/** Cookie to set in the browser before redirecting to the login URL */
|
|
44
|
+
export type AudibleCookie = {
|
|
45
|
+
name: string;
|
|
46
|
+
value: string;
|
|
47
|
+
domain: string;
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,MAAM,MAAM,aAAa,GACrB,IAAI,GACJ,KAAK,GACL,OAAO,GACP,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,QAAQ,GACR,IAAI,GACJ,OAAO,CAAA;AAEX,mDAAmD;AACnD,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAAE,MAAM,CAAA;IACd,aAAa,EAAE,MAAM,CAAA;IACrB,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,qDAAqD;AACrD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,QAAQ,EAAE,MAAM,CAAA;IAChB,gBAAgB,EAAE,MAAM,CAAA;IACxB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,aAAa,CAAA;IACrB,SAAS,EAAE,IAAI,CAAA;CAChB,CAAA;AAED,+CAA+C;AAC/C,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,SAAS,EAAE,MAAM,EAAE,CAAA;IACnB,eAAe,EAAE,MAAM,CAAA;IACvB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,WAAW,CAAC,EAAE,IAAI,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IAC5C,UAAU,CAAC,EAAE,IAAI,CAAA;CAClB,CAAA;AAED,sFAAsF;AACtF,MAAM,MAAM,WAAW,GAAG;IACxB,YAAY,EAAE,MAAM,CAAA;IACpB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,aAAa,CAAA;IACrB,SAAS,EAAE,IAAI,CAAA;CAChB,CAAA;AAED,uEAAuE;AACvE,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACf,CAAA"}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,eAAO,MAAM,SAAS,GAAI,QAAQ,MAAM,WAC8C,CAAA;AAEtF,eAAO,MAAM,WAAW,GAAI,QAAQ,MAAM,WAAiD,CAAA;AAE3F,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,WAAgD,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "audible-api-ts",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A fully typed TypeScript client for the Audible API — authentication, library, and wishlist",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": ["dist"],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "bun run build:js && bun run build:types",
|
|
17
|
+
"build:js": "bun build ./src/index.ts --outdir ./dist --target node --format esm --splitting",
|
|
18
|
+
"build:types": "tsc -p tsconfig.build.json",
|
|
19
|
+
"test": "bun test",
|
|
20
|
+
"lint": "bunx biome check",
|
|
21
|
+
"lint:fix": "bunx biome check --write",
|
|
22
|
+
"docs:dev": "cd docs && bun run dev",
|
|
23
|
+
"docs:build": "cd docs && bun run build",
|
|
24
|
+
"prepublishOnly": "bun run build"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"audible",
|
|
28
|
+
"audiobook",
|
|
29
|
+
"amazon",
|
|
30
|
+
"api",
|
|
31
|
+
"typescript",
|
|
32
|
+
"library",
|
|
33
|
+
"wishlist",
|
|
34
|
+
"pkce",
|
|
35
|
+
"oauth"
|
|
36
|
+
],
|
|
37
|
+
"author": "Thibaut",
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "git+https://github.com/moifort/audible-api-ts.git"
|
|
42
|
+
},
|
|
43
|
+
"bugs": {
|
|
44
|
+
"url": "https://github.com/moifort/audible-api-ts/issues"
|
|
45
|
+
},
|
|
46
|
+
"homepage": "https://moifort.github.io/audible-api-ts",
|
|
47
|
+
"engines": {
|
|
48
|
+
"node": ">=18.0.0"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"zod": "^3.24.0"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@biomejs/biome": "^1.9.0",
|
|
55
|
+
"@types/bun": "^1.2.0",
|
|
56
|
+
"typescript": "^5.7.0"
|
|
57
|
+
}
|
|
58
|
+
}
|