@youversion/platform-core 0.4.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.
Files changed (59) hide show
  1. package/.env.example +7 -0
  2. package/.env.local +10 -0
  3. package/.turbo/turbo-build.log +18 -0
  4. package/CHANGELOG.md +7 -0
  5. package/LICENSE +201 -0
  6. package/README.md +369 -0
  7. package/dist/index.cjs +1330 -0
  8. package/dist/index.d.cts +737 -0
  9. package/dist/index.d.ts +737 -0
  10. package/dist/index.js +1286 -0
  11. package/package.json +46 -0
  12. package/src/AuthenticationStrategy.ts +78 -0
  13. package/src/SignInWithYouVersionResult.ts +53 -0
  14. package/src/StorageStrategy.ts +81 -0
  15. package/src/URLBuilder.ts +71 -0
  16. package/src/Users.ts +137 -0
  17. package/src/WebAuthenticationStrategy.ts +127 -0
  18. package/src/YouVersionAPI.ts +27 -0
  19. package/src/YouVersionPlatformConfiguration.ts +80 -0
  20. package/src/YouVersionUserInfo.ts +49 -0
  21. package/src/__tests__/StorageStrategy.test.ts +404 -0
  22. package/src/__tests__/URLBuilder.test.ts +289 -0
  23. package/src/__tests__/YouVersionPlatformConfiguration.test.ts +150 -0
  24. package/src/__tests__/authentication.test.ts +174 -0
  25. package/src/__tests__/bible.test.ts +356 -0
  26. package/src/__tests__/client.test.ts +109 -0
  27. package/src/__tests__/handlers.ts +41 -0
  28. package/src/__tests__/highlights.test.ts +485 -0
  29. package/src/__tests__/languages.test.ts +139 -0
  30. package/src/__tests__/setup.ts +17 -0
  31. package/src/authentication.ts +27 -0
  32. package/src/bible.ts +272 -0
  33. package/src/client.ts +162 -0
  34. package/src/highlight.ts +16 -0
  35. package/src/highlights.ts +173 -0
  36. package/src/index.ts +20 -0
  37. package/src/languages.ts +80 -0
  38. package/src/schemas/bible-index.ts +48 -0
  39. package/src/schemas/book.ts +34 -0
  40. package/src/schemas/chapter.ts +24 -0
  41. package/src/schemas/collection.ts +28 -0
  42. package/src/schemas/highlight.ts +23 -0
  43. package/src/schemas/index.ts +11 -0
  44. package/src/schemas/language.ts +38 -0
  45. package/src/schemas/passage.ts +14 -0
  46. package/src/schemas/user.ts +10 -0
  47. package/src/schemas/verse.ts +17 -0
  48. package/src/schemas/version.ts +31 -0
  49. package/src/schemas/votd.ts +10 -0
  50. package/src/types/api-config.ts +9 -0
  51. package/src/types/auth.ts +15 -0
  52. package/src/types/book.ts +116 -0
  53. package/src/types/chapter.ts +5 -0
  54. package/src/types/highlight.ts +9 -0
  55. package/src/types/index.ts +22 -0
  56. package/src/utils/constants.ts +219 -0
  57. package/tsconfig.build.json +11 -0
  58. package/tsconfig.json +12 -0
  59. package/vitest.config.ts +9 -0
@@ -0,0 +1,737 @@
1
+ import { z } from 'zod';
2
+
3
+ declare const BibleVersionSchema: z.ZodObject<{
4
+ id: z.ZodNumber;
5
+ abbreviation: z.ZodString;
6
+ copyright_long: z.ZodString;
7
+ copyright_short: z.ZodString;
8
+ info: z.ZodOptional<z.ZodNullable<z.ZodString>>;
9
+ publisher_url: z.ZodOptional<z.ZodNullable<z.ZodURL>>;
10
+ language_tag: z.ZodString;
11
+ local_abbreviation: z.ZodString;
12
+ local_title: z.ZodString;
13
+ title: z.ZodString;
14
+ books: z.ZodArray<z.ZodUnion<readonly [...z.ZodLiteral<"GEN" | "EXO" | "LEV" | "NUM" | "DEU" | "JOS" | "JDG" | "RUT" | "1SA" | "2SA" | "1KI" | "2KI" | "1CH" | "2CH" | "EZR" | "NEH" | "EST" | "JOB" | "PSA" | "PRO" | "ECC" | "SNG" | "ISA" | "JER" | "LAM" | "EZK" | "DAN" | "HOS" | "JOL" | "AMO" | "OBA" | "JON" | "MIC" | "NAM" | "HAB" | "ZEP" | "HAG" | "ZEC" | "MAL" | "MAT" | "MRK" | "LUK" | "JHN" | "ACT" | "ROM" | "1CO" | "2CO" | "GAL" | "EPH" | "PHP" | "COL" | "1TH" | "2TH" | "1TI" | "2TI" | "TIT" | "PHM" | "HEB" | "JAS" | "1PE" | "2PE" | "1JN" | "2JN" | "3JN" | "JUD" | "REV" | "TOB" | "JDT" | "ESG" | "WIS" | "SIR" | "BAR" | "LJE" | "S3Y" | "SUS" | "BEL" | "1MA" | "2MA" | "3MA" | "4MA" | "1ES" | "2ES" | "MAN" | "PS2" | "ODA" | "PSS" | "3ES" | "EZA" | "5EZ" | "6EZ" | "DAG" | "PS3" | "2BA" | "LBA" | "JUB" | "ENO" | "1MQ" | "2MQ" | "3MQ" | "REP" | "4BA" | "LAO" | "LKA">[], z.ZodType<string & {}, unknown, z.core.$ZodTypeInternals<string & {}, unknown>>]>>;
15
+ youversion_deep_link: z.ZodURL;
16
+ }, z.core.$strip>;
17
+ type BibleVersion = z.infer<typeof BibleVersionSchema>;
18
+
19
+ declare const CanonSchema: z.ZodEnum<{
20
+ ot: "ot";
21
+ nt: "nt";
22
+ dc: "dc";
23
+ }>;
24
+ type Canon = z.infer<typeof CanonSchema>;
25
+ declare const BookUsfmSchema: z.ZodUnion<readonly [...z.ZodLiteral<"GEN" | "EXO" | "LEV" | "NUM" | "DEU" | "JOS" | "JDG" | "RUT" | "1SA" | "2SA" | "1KI" | "2KI" | "1CH" | "2CH" | "EZR" | "NEH" | "EST" | "JOB" | "PSA" | "PRO" | "ECC" | "SNG" | "ISA" | "JER" | "LAM" | "EZK" | "DAN" | "HOS" | "JOL" | "AMO" | "OBA" | "JON" | "MIC" | "NAM" | "HAB" | "ZEP" | "HAG" | "ZEC" | "MAL" | "MAT" | "MRK" | "LUK" | "JHN" | "ACT" | "ROM" | "1CO" | "2CO" | "GAL" | "EPH" | "PHP" | "COL" | "1TH" | "2TH" | "1TI" | "2TI" | "TIT" | "PHM" | "HEB" | "JAS" | "1PE" | "2PE" | "1JN" | "2JN" | "3JN" | "JUD" | "REV" | "TOB" | "JDT" | "ESG" | "WIS" | "SIR" | "BAR" | "LJE" | "S3Y" | "SUS" | "BEL" | "1MA" | "2MA" | "3MA" | "4MA" | "1ES" | "2ES" | "MAN" | "PS2" | "ODA" | "PSS" | "3ES" | "EZA" | "5EZ" | "6EZ" | "DAG" | "PS3" | "2BA" | "LBA" | "JUB" | "ENO" | "1MQ" | "2MQ" | "3MQ" | "REP" | "4BA" | "LAO" | "LKA">[], z.ZodType<string & {}, unknown, z.core.$ZodTypeInternals<string & {}, unknown>>]>;
26
+ type BookUsfm = z.infer<typeof BookUsfmSchema>;
27
+ declare const BibleBookSchema: z.ZodObject<{
28
+ id: z.ZodUnion<readonly [...z.ZodLiteral<"GEN" | "EXO" | "LEV" | "NUM" | "DEU" | "JOS" | "JDG" | "RUT" | "1SA" | "2SA" | "1KI" | "2KI" | "1CH" | "2CH" | "EZR" | "NEH" | "EST" | "JOB" | "PSA" | "PRO" | "ECC" | "SNG" | "ISA" | "JER" | "LAM" | "EZK" | "DAN" | "HOS" | "JOL" | "AMO" | "OBA" | "JON" | "MIC" | "NAM" | "HAB" | "ZEP" | "HAG" | "ZEC" | "MAL" | "MAT" | "MRK" | "LUK" | "JHN" | "ACT" | "ROM" | "1CO" | "2CO" | "GAL" | "EPH" | "PHP" | "COL" | "1TH" | "2TH" | "1TI" | "2TI" | "TIT" | "PHM" | "HEB" | "JAS" | "1PE" | "2PE" | "1JN" | "2JN" | "3JN" | "JUD" | "REV" | "TOB" | "JDT" | "ESG" | "WIS" | "SIR" | "BAR" | "LJE" | "S3Y" | "SUS" | "BEL" | "1MA" | "2MA" | "3MA" | "4MA" | "1ES" | "2ES" | "MAN" | "PS2" | "ODA" | "PSS" | "3ES" | "EZA" | "5EZ" | "6EZ" | "DAG" | "PS3" | "2BA" | "LBA" | "JUB" | "ENO" | "1MQ" | "2MQ" | "3MQ" | "REP" | "4BA" | "LAO" | "LKA">[], z.ZodType<string & {}, unknown, z.core.$ZodTypeInternals<string & {}, unknown>>]>;
29
+ title: z.ZodString;
30
+ abbreviation: z.ZodOptional<z.ZodString>;
31
+ canon: z.ZodEnum<{
32
+ ot: "ot";
33
+ nt: "nt";
34
+ dc: "dc";
35
+ }>;
36
+ chapters: z.ZodOptional<z.ZodArray<z.ZodString>>;
37
+ }, z.core.$strip>;
38
+ type BibleBook = z.infer<typeof BibleBookSchema>;
39
+ type CANON = z.infer<typeof CanonSchema>;
40
+
41
+ declare const BibleChapterSchema: z.ZodObject<{
42
+ id: z.ZodString;
43
+ book_id: z.ZodUnion<readonly [...z.ZodLiteral<"GEN" | "EXO" | "LEV" | "NUM" | "DEU" | "JOS" | "JDG" | "RUT" | "1SA" | "2SA" | "1KI" | "2KI" | "1CH" | "2CH" | "EZR" | "NEH" | "EST" | "JOB" | "PSA" | "PRO" | "ECC" | "SNG" | "ISA" | "JER" | "LAM" | "EZK" | "DAN" | "HOS" | "JOL" | "AMO" | "OBA" | "JON" | "MIC" | "NAM" | "HAB" | "ZEP" | "HAG" | "ZEC" | "MAL" | "MAT" | "MRK" | "LUK" | "JHN" | "ACT" | "ROM" | "1CO" | "2CO" | "GAL" | "EPH" | "PHP" | "COL" | "1TH" | "2TH" | "1TI" | "2TI" | "TIT" | "PHM" | "HEB" | "JAS" | "1PE" | "2PE" | "1JN" | "2JN" | "3JN" | "JUD" | "REV" | "TOB" | "JDT" | "ESG" | "WIS" | "SIR" | "BAR" | "LJE" | "S3Y" | "SUS" | "BEL" | "1MA" | "2MA" | "3MA" | "4MA" | "1ES" | "2ES" | "MAN" | "PS2" | "ODA" | "PSS" | "3ES" | "EZA" | "5EZ" | "6EZ" | "DAG" | "PS3" | "2BA" | "LBA" | "JUB" | "ENO" | "1MQ" | "2MQ" | "3MQ" | "REP" | "4BA" | "LAO" | "LKA">[], z.ZodType<string & {}, unknown, z.core.$ZodTypeInternals<string & {}, unknown>>]>;
44
+ passage_id: z.ZodString;
45
+ title: z.ZodString;
46
+ verses: z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<`${number}`, string>>>>;
47
+ }, z.core.$strip>;
48
+ type BibleChapter = z.infer<typeof BibleChapterSchema>;
49
+
50
+ declare const BibleVerseSchema: z.ZodObject<{
51
+ id: z.ZodString;
52
+ book_id: z.ZodUnion<readonly [...z.ZodLiteral<"GEN" | "EXO" | "LEV" | "NUM" | "DEU" | "JOS" | "JDG" | "RUT" | "1SA" | "2SA" | "1KI" | "2KI" | "1CH" | "2CH" | "EZR" | "NEH" | "EST" | "JOB" | "PSA" | "PRO" | "ECC" | "SNG" | "ISA" | "JER" | "LAM" | "EZK" | "DAN" | "HOS" | "JOL" | "AMO" | "OBA" | "JON" | "MIC" | "NAM" | "HAB" | "ZEP" | "HAG" | "ZEC" | "MAL" | "MAT" | "MRK" | "LUK" | "JHN" | "ACT" | "ROM" | "1CO" | "2CO" | "GAL" | "EPH" | "PHP" | "COL" | "1TH" | "2TH" | "1TI" | "2TI" | "TIT" | "PHM" | "HEB" | "JAS" | "1PE" | "2PE" | "1JN" | "2JN" | "3JN" | "JUD" | "REV" | "TOB" | "JDT" | "ESG" | "WIS" | "SIR" | "BAR" | "LJE" | "S3Y" | "SUS" | "BEL" | "1MA" | "2MA" | "3MA" | "4MA" | "1ES" | "2ES" | "MAN" | "PS2" | "ODA" | "PSS" | "3ES" | "EZA" | "5EZ" | "6EZ" | "DAG" | "PS3" | "2BA" | "LBA" | "JUB" | "ENO" | "1MQ" | "2MQ" | "3MQ" | "REP" | "4BA" | "LAO" | "LKA">[], z.ZodType<string & {}, unknown, z.core.$ZodTypeInternals<string & {}, unknown>>]>;
53
+ chapter_id: z.ZodString;
54
+ passage_id: z.ZodString;
55
+ reference: z.ZodString;
56
+ }, z.core.$strip>;
57
+ type BibleVerse = z.infer<typeof BibleVerseSchema>;
58
+
59
+ declare const BiblePassageSchema: z.ZodObject<{
60
+ id: z.ZodString;
61
+ content: z.ZodString;
62
+ bible_id: z.ZodNumber;
63
+ human_reference: z.ZodString;
64
+ }, z.core.$strip>;
65
+ type BiblePassage = z.infer<typeof BiblePassageSchema>;
66
+
67
+ declare const VOTDSchema: z.ZodObject<{
68
+ day: z.ZodNumber;
69
+ passage_id: z.ZodString;
70
+ }, z.core.$strip>;
71
+ type VOTD = z.infer<typeof VOTDSchema>;
72
+
73
+ declare const BibleIndexVerseSchema: z.ZodObject<{
74
+ id: z.ZodString;
75
+ title: z.ZodString;
76
+ }, z.core.$strip>;
77
+ type BibleIndexVerse = z.infer<typeof BibleIndexVerseSchema>;
78
+ declare const BibleIndexChapterSchema: z.ZodObject<{
79
+ id: z.ZodString;
80
+ title: z.ZodString;
81
+ verses: z.ZodArray<z.ZodObject<{
82
+ id: z.ZodString;
83
+ title: z.ZodString;
84
+ }, z.core.$strip>>;
85
+ }, z.core.$strip>;
86
+ type BibleIndexChapter = z.infer<typeof BibleIndexChapterSchema>;
87
+ declare const BibleIndexBookSchema: z.ZodObject<{
88
+ id: z.ZodUnion<readonly [...z.ZodLiteral<"GEN" | "EXO" | "LEV" | "NUM" | "DEU" | "JOS" | "JDG" | "RUT" | "1SA" | "2SA" | "1KI" | "2KI" | "1CH" | "2CH" | "EZR" | "NEH" | "EST" | "JOB" | "PSA" | "PRO" | "ECC" | "SNG" | "ISA" | "JER" | "LAM" | "EZK" | "DAN" | "HOS" | "JOL" | "AMO" | "OBA" | "JON" | "MIC" | "NAM" | "HAB" | "ZEP" | "HAG" | "ZEC" | "MAL" | "MAT" | "MRK" | "LUK" | "JHN" | "ACT" | "ROM" | "1CO" | "2CO" | "GAL" | "EPH" | "PHP" | "COL" | "1TH" | "2TH" | "1TI" | "2TI" | "TIT" | "PHM" | "HEB" | "JAS" | "1PE" | "2PE" | "1JN" | "2JN" | "3JN" | "JUD" | "REV" | "TOB" | "JDT" | "ESG" | "WIS" | "SIR" | "BAR" | "LJE" | "S3Y" | "SUS" | "BEL" | "1MA" | "2MA" | "3MA" | "4MA" | "1ES" | "2ES" | "MAN" | "PS2" | "ODA" | "PSS" | "3ES" | "EZA" | "5EZ" | "6EZ" | "DAG" | "PS3" | "2BA" | "LBA" | "JUB" | "ENO" | "1MQ" | "2MQ" | "3MQ" | "REP" | "4BA" | "LAO" | "LKA">[], z.ZodType<string & {}, unknown, z.core.$ZodTypeInternals<string & {}, unknown>>]>;
89
+ title: z.ZodString;
90
+ full_title: z.ZodString;
91
+ abbreviation: z.ZodString;
92
+ canon: z.ZodEnum<{
93
+ ot: "ot";
94
+ nt: "nt";
95
+ dc: "dc";
96
+ }>;
97
+ chapters: z.ZodArray<z.ZodObject<{
98
+ id: z.ZodString;
99
+ title: z.ZodString;
100
+ verses: z.ZodArray<z.ZodObject<{
101
+ id: z.ZodString;
102
+ title: z.ZodString;
103
+ }, z.core.$strip>>;
104
+ }, z.core.$strip>>;
105
+ }, z.core.$strip>;
106
+ type BibleIndexBook = z.infer<typeof BibleIndexBookSchema>;
107
+ declare const _BibleIndexSchema: z.ZodObject<{
108
+ text_direction: z.ZodString;
109
+ books: z.ZodArray<z.ZodObject<{
110
+ id: z.ZodUnion<readonly [...z.ZodLiteral<"GEN" | "EXO" | "LEV" | "NUM" | "DEU" | "JOS" | "JDG" | "RUT" | "1SA" | "2SA" | "1KI" | "2KI" | "1CH" | "2CH" | "EZR" | "NEH" | "EST" | "JOB" | "PSA" | "PRO" | "ECC" | "SNG" | "ISA" | "JER" | "LAM" | "EZK" | "DAN" | "HOS" | "JOL" | "AMO" | "OBA" | "JON" | "MIC" | "NAM" | "HAB" | "ZEP" | "HAG" | "ZEC" | "MAL" | "MAT" | "MRK" | "LUK" | "JHN" | "ACT" | "ROM" | "1CO" | "2CO" | "GAL" | "EPH" | "PHP" | "COL" | "1TH" | "2TH" | "1TI" | "2TI" | "TIT" | "PHM" | "HEB" | "JAS" | "1PE" | "2PE" | "1JN" | "2JN" | "3JN" | "JUD" | "REV" | "TOB" | "JDT" | "ESG" | "WIS" | "SIR" | "BAR" | "LJE" | "S3Y" | "SUS" | "BEL" | "1MA" | "2MA" | "3MA" | "4MA" | "1ES" | "2ES" | "MAN" | "PS2" | "ODA" | "PSS" | "3ES" | "EZA" | "5EZ" | "6EZ" | "DAG" | "PS3" | "2BA" | "LBA" | "JUB" | "ENO" | "1MQ" | "2MQ" | "3MQ" | "REP" | "4BA" | "LAO" | "LKA">[], z.ZodType<string & {}, unknown, z.core.$ZodTypeInternals<string & {}, unknown>>]>;
111
+ title: z.ZodString;
112
+ full_title: z.ZodString;
113
+ abbreviation: z.ZodString;
114
+ canon: z.ZodEnum<{
115
+ ot: "ot";
116
+ nt: "nt";
117
+ dc: "dc";
118
+ }>;
119
+ chapters: z.ZodArray<z.ZodObject<{
120
+ id: z.ZodString;
121
+ title: z.ZodString;
122
+ verses: z.ZodArray<z.ZodObject<{
123
+ id: z.ZodString;
124
+ title: z.ZodString;
125
+ }, z.core.$strip>>;
126
+ }, z.core.$strip>>;
127
+ }, z.core.$strip>>;
128
+ }, z.core.$strip>;
129
+ type BibleIndex = z.infer<typeof _BibleIndexSchema>;
130
+
131
+ declare const LanguageSchema: z.ZodObject<{
132
+ id: z.ZodString;
133
+ language: z.ZodString;
134
+ script: z.ZodOptional<z.ZodNullable<z.ZodString>>;
135
+ script_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
136
+ aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
137
+ display_names: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
138
+ scripts: z.ZodOptional<z.ZodArray<z.ZodString>>;
139
+ variants: z.ZodOptional<z.ZodArray<z.ZodString>>;
140
+ countries: z.ZodOptional<z.ZodArray<z.ZodString>>;
141
+ text_direction: z.ZodOptional<z.ZodEnum<{
142
+ ltr: "ltr";
143
+ rtl: "rtl";
144
+ }>>;
145
+ writing_population: z.ZodOptional<z.ZodNumber>;
146
+ speaking_population: z.ZodOptional<z.ZodNumber>;
147
+ default_bible_version_id: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
148
+ }, z.core.$strip>;
149
+ type Language = z.infer<typeof LanguageSchema>;
150
+
151
+ declare const _UserSchema: z.ZodObject<{
152
+ avatar_url: z.ZodString;
153
+ first_name: z.ZodString;
154
+ id: z.ZodUUID;
155
+ last_name: z.ZodString;
156
+ }, z.core.$strip>;
157
+ type User = z.infer<typeof _UserSchema>;
158
+
159
+ declare const _HighlightSchema: z.ZodObject<{
160
+ version_id: z.ZodNumber;
161
+ passage_id: z.ZodString;
162
+ color: z.ZodString;
163
+ }, z.core.$strip>;
164
+ type Highlight = z.infer<typeof _HighlightSchema>;
165
+ declare const _CreateHighlightSchema: z.ZodObject<{
166
+ version_id: z.ZodNumber;
167
+ passage_id: z.ZodString;
168
+ color: z.ZodString;
169
+ }, z.core.$strip>;
170
+ type CreateHighlight = z.infer<typeof _CreateHighlightSchema>;
171
+
172
+ /**
173
+ * Generic Collection type for paginated responses
174
+ */
175
+ type Collection<T> = {
176
+ data: T[];
177
+ next_page_token: string | null;
178
+ total_size?: number;
179
+ };
180
+
181
+ interface ApiConfig {
182
+ baseUrl?: string;
183
+ appId: string;
184
+ timeout?: number;
185
+ hostEnv?: string;
186
+ version?: string;
187
+ installationId?: string;
188
+ redirectUri?: string;
189
+ }
190
+
191
+ declare const SignInWithYouVersionPermission: {
192
+ readonly bibles: "bibles";
193
+ readonly highlights: "highlights";
194
+ readonly votd: "votd";
195
+ readonly demographics: "demographics";
196
+ readonly bibleActivity: "bible_activity";
197
+ };
198
+ declare class SignInWithYouVersionResult {
199
+ readonly accessToken: string | null;
200
+ readonly permissions: SignInWithYouVersionPermissionValues[];
201
+ readonly errorMsg: string | null;
202
+ readonly yvpUserId: string | null;
203
+ constructor(url: URL);
204
+ }
205
+
206
+ type SignInWithYouVersionPermissionValues = (typeof SignInWithYouVersionPermission)[keyof typeof SignInWithYouVersionPermission];
207
+ interface AuthenticationState {
208
+ isAuthenticated: boolean;
209
+ isLoading: boolean;
210
+ accessToken: string | null;
211
+ result: SignInWithYouVersionResult | null;
212
+ error: Error | null;
213
+ }
214
+
215
+ /**
216
+ * Legacy type for highlight colors (constants only)
217
+ * Not an API response, so no schema needed
218
+ */
219
+ interface HighlightColor {
220
+ id: number;
221
+ color: string;
222
+ label: string;
223
+ }
224
+
225
+ type QueryParams = Record<string, string | number | boolean>;
226
+ type RequestData = Record<string, string | number | boolean | object>;
227
+ type RequestHeaders = Record<string, string>;
228
+ /**
229
+ * ApiClient is a lightweight HTTP client for interacting with the API using fetch.
230
+ * It provides convenient methods for GET and POST requests with typed responses.
231
+ */
232
+ declare class ApiClient {
233
+ private baseURL;
234
+ private timeout;
235
+ private defaultHeaders;
236
+ config: ApiConfig;
237
+ /**
238
+ * Creates an instance of ApiClient.
239
+ *
240
+ * @param config - The API configuration object containing baseUrl, timeout, and appId.
241
+ */
242
+ constructor(config: ApiConfig);
243
+ /**
244
+ * Builds the query string from parameters
245
+ */
246
+ private buildQueryString;
247
+ /**
248
+ * Makes an HTTP request with timeout support
249
+ */
250
+ private request;
251
+ /**
252
+ * Sends a GET request to the specified API path with optional query parameters.
253
+ *
254
+ * @typeParam T - The expected response type.
255
+ * @param path - The API endpoint path (relative to baseURL).
256
+ * @param params - Optional query parameters to include in the request.
257
+ * @returns A promise resolving to the response data of type T.
258
+ */
259
+ get<T>(path: string, params?: QueryParams, headers?: RequestHeaders): Promise<T>;
260
+ /**
261
+ * Sends a POST request to the specified API path with optional data and query parameters.
262
+ *
263
+ * @typeParam T - The expected response type.
264
+ * @param path - The API endpoint path (relative to baseURL).
265
+ * @param data - Optional request body data to send.
266
+ * @param params - Optional query parameters to include in the request.
267
+ * @returns A promise resolving to the response data of type T.
268
+ */
269
+ post<T>(path: string, data?: RequestData, params?: QueryParams): Promise<T>;
270
+ /**
271
+ * Sends a DELETE request to the specified API path with optional query parameters.
272
+ *
273
+ * @typeParam T - The expected response type.
274
+ * @param path - The API endpoint path (relative to baseURL).
275
+ * @param params - Optional query parameters to include in the request.
276
+ * @returns A promise resolving to the response data of type T (may be empty for 204 responses).
277
+ */
278
+ delete<T>(path: string, params?: QueryParams): Promise<T>;
279
+ }
280
+
281
+ /**
282
+ * Client for interacting with Bible API endpoints.
283
+ */
284
+ declare class BibleClient {
285
+ private client;
286
+ private versionIdSchema;
287
+ private bookSchema;
288
+ private chapterSchema;
289
+ private verseSchema;
290
+ private languageRangesSchema;
291
+ private booleanSchema;
292
+ /**
293
+ * Creates a new BibleClient instance.
294
+ * @param client The API client to use for requests.
295
+ */
296
+ constructor(client: ApiClient);
297
+ private get rootPath();
298
+ /**
299
+ * Fetches a collection of Bible versions filtered by language ranges.
300
+ *
301
+ * @param language_ranges - A comma-separated list of language codes or ranges to filter the versions (required).
302
+ * @param license_id - Optional license ID to filter versions by license.
303
+ * @returns A promise that resolves to a collection of BibleVersion objects.
304
+ */
305
+ getVersions(language_ranges: string, license_id?: string | number): Promise<Collection<BibleVersion>>;
306
+ /**
307
+ * Fetches a Bible version by its ID.
308
+ * @param id The version ID.
309
+ * @returns The requested BibleVersion object.
310
+ */
311
+ getVersion(id: number): Promise<BibleVersion>;
312
+ /**
313
+ * Fetches all books for a given Bible version.
314
+ * @param versionId The version ID.
315
+ * @param canon Optional canon filter ('ot', 'nt', 'deuterocanon').
316
+ * @returns An array of BibleBook objects.
317
+ */
318
+ getBooks(versionId: number, canon?: CANON): Promise<Collection<BibleBook>>;
319
+ /**
320
+ * Fetches a specific book by USFM code for a given version.
321
+ * @param versionId The version ID.
322
+ * @param book The Book Identifier code of the book.
323
+ * @returns The requested BibleBook object.
324
+ */
325
+ getBook(versionId: number, book: string): Promise<BibleBook>;
326
+ /**
327
+ * Fetches all chapters for a specific book in a version.
328
+ * @param versionId The version ID.
329
+ * @param book The Book Identifier code of the book.
330
+ * @returns An array of BibleChapter objects.
331
+ */
332
+ getChapters(versionId: number, book: string): Promise<Collection<BibleChapter>>;
333
+ /**
334
+ * Fetches a specific chapter for a book in a version.
335
+ * @param versionId The version ID.
336
+ * @param book The Book Identifier code of the book (3 characters, e.g., "MAT").
337
+ * @param chapter The chapter number
338
+ * @returns The requested BibleChapter object.
339
+ */
340
+ getChapter(versionId: number, book: string, chapter: number): Promise<BibleChapter>;
341
+ /**
342
+ * Fetches all verses for a specific chapter in a book and version.
343
+ * @param versionId The version ID.
344
+ * @param book The Book Identifier code of the book (3 characters, e.g., "MAT").
345
+ * @param chapter The chapter number.
346
+ * @returns An array of BibleVerse objects.
347
+ */
348
+ getVerses(versionId: number, book: string, chapter: number): Promise<Collection<BibleVerse>>;
349
+ /**
350
+ * Fetches a specific verse from a chapter, book, and version.
351
+ * @param versionId The version ID.
352
+ * @param book The Book Identifier code of the book (3 characters, e.g., "MAT").
353
+ * @param chapter The chapter number.
354
+ * @param verse The verse number.
355
+ * @returns The requested BibleVerse object.
356
+ */
357
+ getVerse(versionId: number, book: string, chapter: number, verse: number): Promise<BibleVerse>;
358
+ /**
359
+ * Fetches a passage (range of verses) from the Bible using the passages endpoint.
360
+ * This is the new API format that returns HTML-formatted content.
361
+ * @param versionId The version ID.
362
+ * @param usfm The USFM reference (e.g., "JHN.3.1-2", "GEN.1", "JHN.3.16").
363
+ * @param format The format to return ("html" or "text", default: "html").
364
+ * @param include_headings Whether to include headings in the content.
365
+ * @param include_notes Whether to include notes in the content.
366
+ * @returns The requested BiblePassage object with HTML content.
367
+ * @example
368
+ * ```ts
369
+ * // Get a single verse
370
+ * const verse = await bibleClient.getPassage(111, "JHN.3.16");
371
+ *
372
+ * // Get a range of verses
373
+ * const verses = await bibleClient.getPassage(111, "JHN.3.1-5");
374
+ *
375
+ * // Get an entire chapter
376
+ * const chapter = await bibleClient.getPassage(111, "GEN.1");
377
+ * ```
378
+ */
379
+ getPassage(versionId: number, usfm: string, format?: 'html' | 'text', include_headings?: boolean, include_notes?: boolean): Promise<BiblePassage>;
380
+ /**
381
+ * Fetches the indexing structure for a Bible version.
382
+ * @param versionId The version ID.
383
+ * @returns The BibleIndex object containing full hierarchy of books, chapters, and verses.
384
+ */
385
+ getIndex(versionId: number): Promise<BibleIndex>;
386
+ /**
387
+ * Fetches the verse of the day calendar for an entire year.
388
+ * @returns A collection of VOTD objects for all days of the year.
389
+ */
390
+ getAllVOTDs(): Promise<Collection<VOTD>>;
391
+ /**
392
+ * Fetches the passage_id for the Verse Of The Day.
393
+ * @param day The day of the year (1-366).
394
+ * @returns The day of the year and the passage_id for that day of the year
395
+ * @example
396
+ * ```ts
397
+ * // Get the passageId for the verse of the first day of the year.
398
+ * const passageId = await bibleClient.getVOTD(1);
399
+ *
400
+ * // Get the passageId for the verse of the 100th day of the year.
401
+ * const passageId = await bibleClient.getVOTD(100);
402
+ * ```
403
+ */
404
+ getVOTD(day: number): Promise<VOTD>;
405
+ }
406
+
407
+ /**
408
+ * Options for getting languages collection.
409
+ */
410
+ type GetLanguagesOptions = {
411
+ page_size?: number;
412
+ page_token?: string;
413
+ country: string;
414
+ };
415
+ /**
416
+ * Client for interacting with Languages API endpoints.
417
+ */
418
+ declare class LanguagesClient {
419
+ private client;
420
+ private languageIdSchema;
421
+ private countrySchema;
422
+ /**
423
+ * Creates a new LanguagesClient instance.
424
+ * @param client The API client to use for requests.
425
+ */
426
+ constructor(client: ApiClient);
427
+ private get rootPath();
428
+ /**
429
+ * Fetches a collection of languages supported in the Platform.
430
+ * @param options Query parameters for pagination and filtering (country is required).
431
+ * @returns A collection of Language objects.
432
+ */
433
+ getLanguages(options: GetLanguagesOptions): Promise<Collection<Language>>;
434
+ /**
435
+ * Fetches details about a specific language in the Platform.
436
+ * @param languageId The BCP 47 language code (optionally including script, e.g., "en" or "sr-Latn").
437
+ * @returns The requested Language object.
438
+ */
439
+ getLanguage(languageId: string): Promise<Language>;
440
+ }
441
+
442
+ /**
443
+ * Options for getting highlights.
444
+ */
445
+ type GetHighlightsOptions = {
446
+ version_id?: number;
447
+ passage_id?: string;
448
+ };
449
+ /**
450
+ * Options for deleting highlights.
451
+ */
452
+ type DeleteHighlightOptions = {
453
+ version_id?: number;
454
+ };
455
+ /**
456
+ * Client for interacting with Highlights API endpoints.
457
+ * Note: All endpoints require OAuth authentication with appropriate scopes.
458
+ */
459
+ declare class HighlightsClient {
460
+ private client;
461
+ private versionIdSchema;
462
+ private passageIdSchema;
463
+ private colorSchema;
464
+ /**
465
+ * Creates a new HighlightsClient instance.
466
+ * @param client The API client to use for requests.
467
+ */
468
+ constructor(client: ApiClient);
469
+ private get rootPath();
470
+ /**
471
+ * Gets the authentication token, either from the provided parameter or from the platform configuration.
472
+ * @param lat Optional explicit long access token. If not provided, retrieves from YouVersionPlatformConfiguration.
473
+ * @returns The authentication token.
474
+ * @throws Error if no token is available.
475
+ */
476
+ private getAuthToken;
477
+ private validateVersionId;
478
+ private validatePassageId;
479
+ private validateColor;
480
+ /**
481
+ * Fetches a collection of highlights for a user.
482
+ * The response will return a color per verse without ranges.
483
+ * Requires OAuth with read_highlights scope.
484
+ * @param options Query parameters for filtering highlights.
485
+ * @param lat Optional long access token. If not provided, retrieves from YouVersionPlatformConfiguration.
486
+ * @returns A collection of Highlight objects.
487
+ */
488
+ getHighlights(options?: GetHighlightsOptions, lat?: string): Promise<Collection<Highlight>>;
489
+ /**
490
+ * Creates or updates a highlight on a passage.
491
+ * Verse ranges may be used in the passage_id attribute.
492
+ * Requires OAuth with write_highlights scope.
493
+ * @param data The highlight data to create or update.
494
+ * @param lat Optional long access token. If not provided, retrieves from YouVersionPlatformConfiguration.
495
+ * @returns The created or updated Highlight object.
496
+ */
497
+ createHighlight(data: CreateHighlight, lat?: string): Promise<Highlight>;
498
+ /**
499
+ * Clears highlights for a passage.
500
+ * Requires OAuth with write_highlights scope.
501
+ * @param passageId The passage identifier (USFM format, e.g., "MAT.1.1" or "MAT.1.1-5").
502
+ * @param options Optional query parameters including bible_id.
503
+ * @param lat Optional long access token. If not provided, retrieves from YouVersionPlatformConfiguration.
504
+ * @returns Promise that resolves when highlights are deleted (204 response).
505
+ */
506
+ deleteHighlight(passageId: string, options?: DeleteHighlightOptions, lat?: string): Promise<void>;
507
+ }
508
+
509
+ /**
510
+ * Client for authentication-related API calls.
511
+ */
512
+ declare class AuthClient {
513
+ private client;
514
+ /**
515
+ * Creates an instance of AuthClient.
516
+ * @param client - The ApiClient instance to use for requests.
517
+ */
518
+ constructor(client: ApiClient);
519
+ /**
520
+ * Retrieves the current authenticated user.
521
+ *
522
+ * @param lat - The long access token (LAT) used for authentication.
523
+ * @returns A promise that resolves to the authenticated User.
524
+ */
525
+ getUser(lat: string): Promise<User>;
526
+ }
527
+
528
+ /**
529
+ * Platform-agnostic authentication strategy interface
530
+ *
531
+ * Implementations should handle platform-specific authentication flows
532
+ * and return the callback URL containing the authentication result.
533
+ */
534
+ interface AuthenticationStrategy {
535
+ /**
536
+ * Opens the authentication flow and returns the callback URL
537
+ *
538
+ * @param authUrl - The YouVersion authorization URL to open
539
+ * @returns Promise that resolves to the callback URL with auth result
540
+ * @throws Error if authentication fails or is cancelled
541
+ */
542
+ authenticate(authUrl: URL): Promise<URL>;
543
+ }
544
+ /**
545
+ * Registry for platform-specific authentication strategies
546
+ *
547
+ * This singleton registry manages the current authentication strategy
548
+ * and ensures only one strategy is active at a time.
549
+ */
550
+ declare class AuthenticationStrategyRegistry {
551
+ private static strategy;
552
+ /**
553
+ * Registers a platform-specific authentication strategy
554
+ *
555
+ * @param strategy - The authentication strategy to register
556
+ * @throws Error if strategy is null, undefined, or missing required methods
557
+ */
558
+ static register(strategy: AuthenticationStrategy): void;
559
+ /**
560
+ * Gets the currently registered authentication strategy
561
+ *
562
+ * @returns The registered authentication strategy
563
+ * @throws Error if no strategy has been registered
564
+ */
565
+ static get(): AuthenticationStrategy;
566
+ /**
567
+ * Checks if a strategy is currently registered
568
+ *
569
+ * @returns true if a strategy is registered, false otherwise
570
+ */
571
+ static isRegistered(): boolean;
572
+ /**
573
+ * Resets the registry by removing the current strategy
574
+ *
575
+ * This method is primarily intended for testing scenarios
576
+ * where you need to clean up between test cases.
577
+ */
578
+ static reset(): void;
579
+ }
580
+
581
+ /**
582
+ * Abstract storage strategy for auth-related data (callbacks, return URLs).
583
+ * Implementations can use different mechanisms (sessionStorage, memory, etc.)
584
+ *
585
+ * WARNING: Session storage has known XSS vulnerabilities. An attacker that gains
586
+ * script execution access (via XSS) can read all values in sessionStorage. Consider
587
+ * using a secure, HTTP-only cookie mechanism for production applications.
588
+ */
589
+ interface StorageStrategy {
590
+ setItem(key: string, value: string): void;
591
+ getItem(key: string): string | null;
592
+ removeItem(key: string): void;
593
+ clear(): void;
594
+ }
595
+ /**
596
+ * Default storage strategy using the browser's sessionStorage.
597
+ * This provides temporary storage for authentication state during a single session.
598
+ *
599
+ * SECURITY WARNING: SessionStorage is vulnerable to XSS attacks. If an attacker
600
+ * can inject JavaScript into your application, they can access all sessionStorage values.
601
+ * For production applications handling sensitive authentication tokens, consider:
602
+ * 1. Using secure, HTTP-only cookies instead
603
+ * 2. Storing tokens in memory only (with redirection to re-authenticate on page reload)
604
+ * 3. Using a custom storage backend that implements additional security measures
605
+ */
606
+ declare class SessionStorageStrategy implements StorageStrategy {
607
+ setItem(key: string, value: string): void;
608
+ getItem(key: string): string | null;
609
+ removeItem(key: string): void;
610
+ clear(): void;
611
+ }
612
+ /**
613
+ * In-memory storage strategy that stores data in a Map.
614
+ * This storage is cleared when the page is refreshed.
615
+ * Provides better XSS protection than sessionStorage but requires re-authentication on page reload.
616
+ */
617
+ declare class MemoryStorageStrategy implements StorageStrategy {
618
+ private store;
619
+ setItem(key: string, value: string): void;
620
+ getItem(key: string): string | null;
621
+ removeItem(key: string): void;
622
+ clear(): void;
623
+ }
624
+
625
+ declare class WebAuthenticationStrategy implements AuthenticationStrategy {
626
+ private redirectUri;
627
+ private callbackPath;
628
+ private timeout;
629
+ private storage;
630
+ private static pendingAuthResolve;
631
+ private static pendingAuthReject;
632
+ private static timeoutId;
633
+ constructor(options?: {
634
+ redirectUri?: string;
635
+ callbackPath?: string;
636
+ timeout?: number;
637
+ storage?: StorageStrategy;
638
+ });
639
+ authenticate(authUrl: URL): Promise<URL>;
640
+ /**
641
+ * Call this method when your app loads to handle the redirect callback
642
+ */
643
+ static handleCallback(callbackPath?: string): boolean;
644
+ /**
645
+ * Clean up pending authentication state
646
+ */
647
+ static cleanup(): void;
648
+ /**
649
+ * Retrieve stored callback result if available
650
+ */
651
+ static getStoredCallback(): URL | null;
652
+ private authenticateWithRedirect;
653
+ }
654
+
655
+ interface YouVersionUserInfoJSON {
656
+ first_name?: string;
657
+ last_name?: string;
658
+ id?: string;
659
+ avatar_url?: string;
660
+ }
661
+ declare class YouVersionUserInfo {
662
+ readonly firstName?: string;
663
+ readonly lastName?: string;
664
+ readonly userId?: string;
665
+ readonly avatarUrlFormat?: string;
666
+ constructor(data: YouVersionUserInfoJSON);
667
+ getAvatarUrl(width?: number, height?: number): URL | null;
668
+ get avatarUrl(): URL | null;
669
+ }
670
+
671
+ declare class YouVersionAPIUsers {
672
+ /**
673
+ * Presents the YouVersion login flow to the user and returns the login result upon completion.
674
+ *
675
+ * This function authenticates the user with YouVersion, requesting the specified required and optional permissions.
676
+ * The function returns a promise that resolves when the user completes or cancels the login flow,
677
+ * returning the login result containing the authorization code and granted permissions.
678
+ *
679
+ * @param requiredPermissions - The set of permissions that must be granted by the user for successful login.
680
+ * @param optionalPermissions - The set of permissions that will be requested from the user but are not required for successful login.
681
+ * @returns A Promise resolving to a SignInWithYouVersionResult containing the authorization code and granted permissions upon successful login.
682
+ * @throws An error if authentication fails or is cancelled by the user.
683
+ */
684
+ static signIn(requiredPermissions: Set<SignInWithYouVersionPermissionValues>, optionalPermissions: Set<SignInWithYouVersionPermissionValues>): Promise<SignInWithYouVersionResult>;
685
+ static signOut(): void;
686
+ /**
687
+ * Retrieves user information for the authenticated user using the provided access token.
688
+ *
689
+ * This function fetches the user's profile information from the YouVersion API, decoding it into a YouVersionUserInfo model.
690
+ *
691
+ * @param accessToken - The access token obtained from the login process.
692
+ * @returns A Promise resolving to a YouVersionUserInfo object containing the user's profile information.
693
+ * @throws An error if the URL is invalid, the network request fails, or the response cannot be decoded.
694
+ */
695
+ static userInfo(accessToken: string): Promise<YouVersionUserInfo>;
696
+ }
697
+
698
+ declare class YouVersionAPI {
699
+ static addStandardHeaders(url: URL): Request;
700
+ }
701
+
702
+ declare class URLBuilder {
703
+ private static get baseURL();
704
+ static authURL(appId: string, requiredPermissions?: Set<SignInWithYouVersionPermissionValues>, optionalPermissions?: Set<SignInWithYouVersionPermissionValues>): URL;
705
+ static userURL(accessToken: string): URL;
706
+ }
707
+
708
+ declare class YouVersionPlatformConfiguration {
709
+ private static _appId;
710
+ private static _installationId;
711
+ private static _accessToken;
712
+ private static _apiHost;
713
+ private static _isPreviewMode;
714
+ private static _previewUserInfo;
715
+ private static getOrSetInstallationId;
716
+ static get appId(): string | null;
717
+ static set appId(value: string | null);
718
+ static get installationId(): string;
719
+ static set installationId(value: string | null);
720
+ static setAccessToken(token: string | null): void;
721
+ static get accessToken(): string | null;
722
+ static get apiHost(): string;
723
+ static set apiHost(value: string);
724
+ static get isPreviewMode(): boolean;
725
+ static set isPreviewMode(value: boolean);
726
+ static get previewUserInfo(): YouVersionUserInfo | null;
727
+ static set previewUserInfo(value: YouVersionUserInfo | null);
728
+ }
729
+
730
+ declare const BOOK_IDS: readonly ["GEN", "EXO", "LEV", "NUM", "DEU", "JOS", "JDG", "RUT", "1SA", "2SA", "1KI", "2KI", "1CH", "2CH", "EZR", "NEH", "EST", "JOB", "PSA", "PRO", "ECC", "SNG", "ISA", "JER", "LAM", "EZK", "DAN", "HOS", "JOL", "AMO", "OBA", "JON", "MIC", "NAM", "HAB", "ZEP", "HAG", "ZEC", "MAL", "MAT", "MRK", "LUK", "JHN", "ACT", "ROM", "1CO", "2CO", "GAL", "EPH", "PHP", "COL", "1TH", "2TH", "1TI", "2TI", "TIT", "PHM", "HEB", "JAS", "1PE", "2PE", "1JN", "2JN", "3JN", "JUD", "REV", "TOB", "JDT", "ESG", "WIS", "SIR", "BAR", "LJE", "S3Y", "SUS", "BEL", "1MA", "2MA", "3MA", "4MA", "1ES", "2ES", "MAN", "PS2", "ODA", "PSS", "3ES", "EZA", "5EZ", "6EZ", "DAG", "PS3", "2BA", "LBA", "JUB", "ENO", "1MQ", "2MQ", "3MQ", "REP", "4BA", "LAO", "LKA"];
731
+
732
+ /**
733
+ * @see https://github.com/youversion/usfm-references/blob/main/usfm_references/books.py
734
+ */
735
+ declare const BOOK_CANON: Record<BookUsfm, Canon>;
736
+
737
+ export { ApiClient, type ApiConfig, AuthClient, type AuthenticationState, type AuthenticationStrategy, AuthenticationStrategyRegistry, BOOK_CANON, BOOK_IDS, type BibleBook, type BibleChapter, BibleClient, type BibleIndex, type BibleIndexBook, type BibleIndexChapter, type BibleIndexVerse, type BiblePassage, type BibleVerse, type BibleVersion, type CANON, type Collection, type CreateHighlight, type DeleteHighlightOptions, type GetHighlightsOptions, type GetLanguagesOptions, type Highlight, type HighlightColor, HighlightsClient, type Language, LanguagesClient, MemoryStorageStrategy, SessionStorageStrategy, SignInWithYouVersionPermission, type SignInWithYouVersionPermissionValues, SignInWithYouVersionResult, type StorageStrategy, URLBuilder, type User, type VOTD, WebAuthenticationStrategy, YouVersionAPI, YouVersionAPIUsers, YouVersionPlatformConfiguration, YouVersionUserInfo, type YouVersionUserInfoJSON };