@youversion/platform-core 1.20.1 → 1.20.2
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/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +6 -0
- package/dist/index.cjs +4 -1
- package/dist/index.d.cts +34 -41
- package/dist/index.d.ts +34 -41
- package/dist/index.js +3 -1
- package/package.json +3 -3
- package/src/schemas/book.ts +3 -5
- package/src/types/index.ts +32 -8
- package/src/utils/constants.ts +5 -3
- package/src/__tests__/mocks/configuration.ts +0 -53
- package/src/__tests__/mocks/jwt.ts +0 -93
- package/src/__tests__/mocks/tokens.ts +0 -69
- package/src/highlight.ts +0 -16
- package/src/types/api-config.ts +0 -7
- package/src/types/auth.ts +0 -18
- package/src/types/highlight.ts +0 -9
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @youversion/platform-core@1.20.
|
|
2
|
+
> @youversion/platform-core@1.20.2 build /home/runner/work/platform-sdk-react/platform-sdk-react/packages/core
|
|
3
3
|
> tsup src/index.ts --format cjs,esm --dts
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
[34mCLI[39m Target: es2022
|
|
9
9
|
[34mCJS[39m Build start
|
|
10
10
|
[34mESM[39m Build start
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
11
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m56.19 KB[39m
|
|
12
|
+
[32mCJS[39m ⚡️ Build success in 59ms
|
|
13
|
+
[32mESM[39m [1mdist/index.js [22m[32m53.04 KB[39m
|
|
14
|
+
[32mESM[39m ⚡️ Build success in 59ms
|
|
15
15
|
[34mDTS[39m Build start
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
17
|
-
[32mDTS[39m [1mdist/index.d.cts [22m[
|
|
18
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 1992ms
|
|
17
|
+
[32mDTS[39m [1mdist/index.d.cts [22m[32m33.09 KB[39m
|
|
18
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m33.09 KB[39m
|
package/CHANGELOG.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -24,6 +24,7 @@ __export(index_exports, {
|
|
|
24
24
|
BOOK_CANON: () => BOOK_CANON,
|
|
25
25
|
BOOK_IDS: () => BOOK_IDS,
|
|
26
26
|
BibleClient: () => BibleClient,
|
|
27
|
+
CANON_IDS: () => CANON_IDS,
|
|
27
28
|
DEFAULT_LICENSE_FREE_BIBLE_VERSION: () => DEFAULT_LICENSE_FREE_BIBLE_VERSION,
|
|
28
29
|
HighlightsClient: () => HighlightsClient,
|
|
29
30
|
LanguagesClient: () => LanguagesClient,
|
|
@@ -203,6 +204,7 @@ var import_zod3 = require("zod");
|
|
|
203
204
|
|
|
204
205
|
// src/utils/constants.ts
|
|
205
206
|
var DEFAULT_LICENSE_FREE_BIBLE_VERSION = 3034;
|
|
207
|
+
var CANON_IDS = ["old_testament", "new_testament", "deuterocanon"];
|
|
206
208
|
var BOOK_IDS = [
|
|
207
209
|
"GEN",
|
|
208
210
|
"EXO",
|
|
@@ -444,7 +446,7 @@ var BibleChapterSchema = import_zod2.z.object({
|
|
|
444
446
|
});
|
|
445
447
|
|
|
446
448
|
// src/schemas/book.ts
|
|
447
|
-
var CanonSchema = import_zod3.z.enum(
|
|
449
|
+
var CanonSchema = import_zod3.z.enum(CANON_IDS);
|
|
448
450
|
var BibleBookIntroSchema = import_zod3.z.object({
|
|
449
451
|
/** Intro identifier */
|
|
450
452
|
id: import_zod3.z.string(),
|
|
@@ -1736,6 +1738,7 @@ function lastCanonicalOfPreviousBook(books, bookIndex) {
|
|
|
1736
1738
|
BOOK_CANON,
|
|
1737
1739
|
BOOK_IDS,
|
|
1738
1740
|
BibleClient,
|
|
1741
|
+
CANON_IDS,
|
|
1739
1742
|
DEFAULT_LICENSE_FREE_BIBLE_VERSION,
|
|
1740
1743
|
HighlightsClient,
|
|
1741
1744
|
LanguagesClient,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
+
declare const SignInWithYouVersionPermission: {
|
|
4
|
+
readonly bibles: "bibles";
|
|
5
|
+
readonly highlights: "highlights";
|
|
6
|
+
readonly votd: "votd";
|
|
7
|
+
readonly demographics: "demographics";
|
|
8
|
+
readonly bibleActivity: "bible_activity";
|
|
9
|
+
};
|
|
10
|
+
type SignInWithYouVersionResultProps = {
|
|
11
|
+
accessToken?: string;
|
|
12
|
+
expiresIn?: number;
|
|
13
|
+
refreshToken?: string;
|
|
14
|
+
idToken?: string;
|
|
15
|
+
yvpUserId?: string;
|
|
16
|
+
name?: string;
|
|
17
|
+
profilePicture?: string;
|
|
18
|
+
email?: string;
|
|
19
|
+
};
|
|
20
|
+
declare class SignInWithYouVersionResult {
|
|
21
|
+
readonly accessToken: string | undefined;
|
|
22
|
+
readonly expiryDate: Date | undefined;
|
|
23
|
+
readonly refreshToken: string | undefined;
|
|
24
|
+
readonly idToken: string | undefined;
|
|
25
|
+
readonly yvpUserId: string | undefined;
|
|
26
|
+
readonly name: string | undefined;
|
|
27
|
+
readonly profilePicture: string | undefined;
|
|
28
|
+
readonly email: string | undefined;
|
|
29
|
+
constructor({ accessToken, expiresIn, refreshToken, idToken, yvpUserId, name, profilePicture, email, }: SignInWithYouVersionResultProps);
|
|
30
|
+
}
|
|
31
|
+
|
|
3
32
|
declare const BibleVersionSchema: z.ZodObject<{
|
|
4
33
|
id: z.ZodNumber;
|
|
5
34
|
abbreviation: z.ZodString;
|
|
@@ -22,15 +51,12 @@ declare const CanonSchema: z.ZodEnum<{
|
|
|
22
51
|
new_testament: "new_testament";
|
|
23
52
|
deuterocanon: "deuterocanon";
|
|
24
53
|
}>;
|
|
25
|
-
type Canon = Readonly<z.infer<typeof CanonSchema>>;
|
|
26
54
|
declare const BibleBookIntroSchema: z.ZodObject<{
|
|
27
55
|
id: z.ZodString;
|
|
28
56
|
passage_id: z.ZodString;
|
|
29
57
|
title: z.ZodString;
|
|
30
58
|
}, z.core.$strip>;
|
|
31
59
|
type BibleBookIntro = Readonly<z.infer<typeof BibleBookIntroSchema>>;
|
|
32
|
-
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>>]>;
|
|
33
|
-
type BookUsfm = z.infer<typeof BookUsfmSchema>;
|
|
34
60
|
declare const BibleBookSchema: z.ZodObject<{
|
|
35
61
|
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>>]>;
|
|
36
62
|
title: z.ZodString;
|
|
@@ -207,36 +233,6 @@ interface ApiConfig {
|
|
|
207
233
|
installationId?: string;
|
|
208
234
|
redirectUri?: string;
|
|
209
235
|
}
|
|
210
|
-
|
|
211
|
-
declare const SignInWithYouVersionPermission: {
|
|
212
|
-
readonly bibles: "bibles";
|
|
213
|
-
readonly highlights: "highlights";
|
|
214
|
-
readonly votd: "votd";
|
|
215
|
-
readonly demographics: "demographics";
|
|
216
|
-
readonly bibleActivity: "bible_activity";
|
|
217
|
-
};
|
|
218
|
-
type SignInWithYouVersionResultProps = {
|
|
219
|
-
accessToken?: string;
|
|
220
|
-
expiresIn?: number;
|
|
221
|
-
refreshToken?: string;
|
|
222
|
-
idToken?: string;
|
|
223
|
-
yvpUserId?: string;
|
|
224
|
-
name?: string;
|
|
225
|
-
profilePicture?: string;
|
|
226
|
-
email?: string;
|
|
227
|
-
};
|
|
228
|
-
declare class SignInWithYouVersionResult {
|
|
229
|
-
readonly accessToken: string | undefined;
|
|
230
|
-
readonly expiryDate: Date | undefined;
|
|
231
|
-
readonly refreshToken: string | undefined;
|
|
232
|
-
readonly idToken: string | undefined;
|
|
233
|
-
readonly yvpUserId: string | undefined;
|
|
234
|
-
readonly name: string | undefined;
|
|
235
|
-
readonly profilePicture: string | undefined;
|
|
236
|
-
readonly email: string | undefined;
|
|
237
|
-
constructor({ accessToken, expiresIn, refreshToken, idToken, yvpUserId, name, profilePicture, email, }: SignInWithYouVersionResultProps);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
236
|
type SignInWithYouVersionPermissionValues = (typeof SignInWithYouVersionPermission)[keyof typeof SignInWithYouVersionPermission];
|
|
241
237
|
interface AuthenticationState {
|
|
242
238
|
readonly isAuthenticated: boolean;
|
|
@@ -247,11 +243,6 @@ interface AuthenticationState {
|
|
|
247
243
|
readonly error: Error | null;
|
|
248
244
|
}
|
|
249
245
|
type AuthenticationScopes = 'profile' | 'email';
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* Legacy type for highlight colors (constants only)
|
|
253
|
-
* Not an API response, so no schema needed
|
|
254
|
-
*/
|
|
255
246
|
interface HighlightColor {
|
|
256
247
|
id: number;
|
|
257
248
|
color: string;
|
|
@@ -724,12 +715,14 @@ declare class YouVersionPlatformConfiguration {
|
|
|
724
715
|
* a good use-case for a default Bible Version.
|
|
725
716
|
*/
|
|
726
717
|
declare const DEFAULT_LICENSE_FREE_BIBLE_VERSION: 3034;
|
|
718
|
+
declare const CANON_IDS: readonly ["old_testament", "new_testament", "deuterocanon"];
|
|
727
719
|
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"];
|
|
728
|
-
|
|
720
|
+
type CanonId = (typeof CANON_IDS)[number];
|
|
721
|
+
type KnownBookUsfm = (typeof BOOK_IDS)[number];
|
|
729
722
|
/**
|
|
730
723
|
* @see https://github.com/youversion/usfm-references/blob/main/usfm_references/books.py
|
|
731
724
|
*/
|
|
732
|
-
declare const BOOK_CANON: Record<
|
|
725
|
+
declare const BOOK_CANON: Record<KnownBookUsfm, CanonId>;
|
|
733
726
|
|
|
734
727
|
type AdjacentChapterResult = {
|
|
735
728
|
bookId: string;
|
|
@@ -746,4 +739,4 @@ type AdjacentChapterResult = {
|
|
|
746
739
|
*/
|
|
747
740
|
declare function getAdjacentChapter(books: BibleBook[], currentBookId: string, currentChapterId: string, direction: 'next' | 'previous'): AdjacentChapterResult;
|
|
748
741
|
|
|
749
|
-
export { ApiClient, type ApiConfig, type AuthenticationScopes, type AuthenticationState, BOOK_CANON, BOOK_IDS, type BibleBook, type BibleBookIntro, type BibleChapter, BibleClient, type BibleIndex, type BibleIndexBook, type BibleIndexChapter, type BibleIndexVerse, type BiblePassage, type BibleVerse, type BibleVersion, type CANON, type Collection, type CreateHighlight, DEFAULT_LICENSE_FREE_BIBLE_VERSION, type DeleteHighlightOptions, type GetHighlightsOptions, type GetLanguagesOptions, type Highlight, type HighlightColor, HighlightsClient, type Language, LanguagesClient, MemoryStorageStrategy, SessionStorageStrategy, SignInWithYouVersionPermission, type SignInWithYouVersionPermissionValues, SignInWithYouVersionResult, type StorageStrategy, type User, type VOTD, YouVersionAPI, YouVersionAPIUsers, YouVersionPlatformConfiguration, YouVersionUserInfo, type YouVersionUserInfoJSON, getAdjacentChapter };
|
|
742
|
+
export { ApiClient, type ApiConfig, type AuthenticationScopes, type AuthenticationState, BOOK_CANON, BOOK_IDS, type BibleBook, type BibleBookIntro, type BibleChapter, BibleClient, type BibleIndex, type BibleIndexBook, type BibleIndexChapter, type BibleIndexVerse, type BiblePassage, type BibleVerse, type BibleVersion, type CANON, CANON_IDS, type Collection, type CreateHighlight, DEFAULT_LICENSE_FREE_BIBLE_VERSION, type DeleteHighlightOptions, type GetHighlightsOptions, type GetLanguagesOptions, type Highlight, type HighlightColor, HighlightsClient, type Language, LanguagesClient, MemoryStorageStrategy, SessionStorageStrategy, SignInWithYouVersionPermission, type SignInWithYouVersionPermissionValues, SignInWithYouVersionResult, type StorageStrategy, type User, type VOTD, YouVersionAPI, YouVersionAPIUsers, YouVersionPlatformConfiguration, YouVersionUserInfo, type YouVersionUserInfoJSON, getAdjacentChapter };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
+
declare const SignInWithYouVersionPermission: {
|
|
4
|
+
readonly bibles: "bibles";
|
|
5
|
+
readonly highlights: "highlights";
|
|
6
|
+
readonly votd: "votd";
|
|
7
|
+
readonly demographics: "demographics";
|
|
8
|
+
readonly bibleActivity: "bible_activity";
|
|
9
|
+
};
|
|
10
|
+
type SignInWithYouVersionResultProps = {
|
|
11
|
+
accessToken?: string;
|
|
12
|
+
expiresIn?: number;
|
|
13
|
+
refreshToken?: string;
|
|
14
|
+
idToken?: string;
|
|
15
|
+
yvpUserId?: string;
|
|
16
|
+
name?: string;
|
|
17
|
+
profilePicture?: string;
|
|
18
|
+
email?: string;
|
|
19
|
+
};
|
|
20
|
+
declare class SignInWithYouVersionResult {
|
|
21
|
+
readonly accessToken: string | undefined;
|
|
22
|
+
readonly expiryDate: Date | undefined;
|
|
23
|
+
readonly refreshToken: string | undefined;
|
|
24
|
+
readonly idToken: string | undefined;
|
|
25
|
+
readonly yvpUserId: string | undefined;
|
|
26
|
+
readonly name: string | undefined;
|
|
27
|
+
readonly profilePicture: string | undefined;
|
|
28
|
+
readonly email: string | undefined;
|
|
29
|
+
constructor({ accessToken, expiresIn, refreshToken, idToken, yvpUserId, name, profilePicture, email, }: SignInWithYouVersionResultProps);
|
|
30
|
+
}
|
|
31
|
+
|
|
3
32
|
declare const BibleVersionSchema: z.ZodObject<{
|
|
4
33
|
id: z.ZodNumber;
|
|
5
34
|
abbreviation: z.ZodString;
|
|
@@ -22,15 +51,12 @@ declare const CanonSchema: z.ZodEnum<{
|
|
|
22
51
|
new_testament: "new_testament";
|
|
23
52
|
deuterocanon: "deuterocanon";
|
|
24
53
|
}>;
|
|
25
|
-
type Canon = Readonly<z.infer<typeof CanonSchema>>;
|
|
26
54
|
declare const BibleBookIntroSchema: z.ZodObject<{
|
|
27
55
|
id: z.ZodString;
|
|
28
56
|
passage_id: z.ZodString;
|
|
29
57
|
title: z.ZodString;
|
|
30
58
|
}, z.core.$strip>;
|
|
31
59
|
type BibleBookIntro = Readonly<z.infer<typeof BibleBookIntroSchema>>;
|
|
32
|
-
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>>]>;
|
|
33
|
-
type BookUsfm = z.infer<typeof BookUsfmSchema>;
|
|
34
60
|
declare const BibleBookSchema: z.ZodObject<{
|
|
35
61
|
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>>]>;
|
|
36
62
|
title: z.ZodString;
|
|
@@ -207,36 +233,6 @@ interface ApiConfig {
|
|
|
207
233
|
installationId?: string;
|
|
208
234
|
redirectUri?: string;
|
|
209
235
|
}
|
|
210
|
-
|
|
211
|
-
declare const SignInWithYouVersionPermission: {
|
|
212
|
-
readonly bibles: "bibles";
|
|
213
|
-
readonly highlights: "highlights";
|
|
214
|
-
readonly votd: "votd";
|
|
215
|
-
readonly demographics: "demographics";
|
|
216
|
-
readonly bibleActivity: "bible_activity";
|
|
217
|
-
};
|
|
218
|
-
type SignInWithYouVersionResultProps = {
|
|
219
|
-
accessToken?: string;
|
|
220
|
-
expiresIn?: number;
|
|
221
|
-
refreshToken?: string;
|
|
222
|
-
idToken?: string;
|
|
223
|
-
yvpUserId?: string;
|
|
224
|
-
name?: string;
|
|
225
|
-
profilePicture?: string;
|
|
226
|
-
email?: string;
|
|
227
|
-
};
|
|
228
|
-
declare class SignInWithYouVersionResult {
|
|
229
|
-
readonly accessToken: string | undefined;
|
|
230
|
-
readonly expiryDate: Date | undefined;
|
|
231
|
-
readonly refreshToken: string | undefined;
|
|
232
|
-
readonly idToken: string | undefined;
|
|
233
|
-
readonly yvpUserId: string | undefined;
|
|
234
|
-
readonly name: string | undefined;
|
|
235
|
-
readonly profilePicture: string | undefined;
|
|
236
|
-
readonly email: string | undefined;
|
|
237
|
-
constructor({ accessToken, expiresIn, refreshToken, idToken, yvpUserId, name, profilePicture, email, }: SignInWithYouVersionResultProps);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
236
|
type SignInWithYouVersionPermissionValues = (typeof SignInWithYouVersionPermission)[keyof typeof SignInWithYouVersionPermission];
|
|
241
237
|
interface AuthenticationState {
|
|
242
238
|
readonly isAuthenticated: boolean;
|
|
@@ -247,11 +243,6 @@ interface AuthenticationState {
|
|
|
247
243
|
readonly error: Error | null;
|
|
248
244
|
}
|
|
249
245
|
type AuthenticationScopes = 'profile' | 'email';
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* Legacy type for highlight colors (constants only)
|
|
253
|
-
* Not an API response, so no schema needed
|
|
254
|
-
*/
|
|
255
246
|
interface HighlightColor {
|
|
256
247
|
id: number;
|
|
257
248
|
color: string;
|
|
@@ -724,12 +715,14 @@ declare class YouVersionPlatformConfiguration {
|
|
|
724
715
|
* a good use-case for a default Bible Version.
|
|
725
716
|
*/
|
|
726
717
|
declare const DEFAULT_LICENSE_FREE_BIBLE_VERSION: 3034;
|
|
718
|
+
declare const CANON_IDS: readonly ["old_testament", "new_testament", "deuterocanon"];
|
|
727
719
|
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"];
|
|
728
|
-
|
|
720
|
+
type CanonId = (typeof CANON_IDS)[number];
|
|
721
|
+
type KnownBookUsfm = (typeof BOOK_IDS)[number];
|
|
729
722
|
/**
|
|
730
723
|
* @see https://github.com/youversion/usfm-references/blob/main/usfm_references/books.py
|
|
731
724
|
*/
|
|
732
|
-
declare const BOOK_CANON: Record<
|
|
725
|
+
declare const BOOK_CANON: Record<KnownBookUsfm, CanonId>;
|
|
733
726
|
|
|
734
727
|
type AdjacentChapterResult = {
|
|
735
728
|
bookId: string;
|
|
@@ -746,4 +739,4 @@ type AdjacentChapterResult = {
|
|
|
746
739
|
*/
|
|
747
740
|
declare function getAdjacentChapter(books: BibleBook[], currentBookId: string, currentChapterId: string, direction: 'next' | 'previous'): AdjacentChapterResult;
|
|
748
741
|
|
|
749
|
-
export { ApiClient, type ApiConfig, type AuthenticationScopes, type AuthenticationState, BOOK_CANON, BOOK_IDS, type BibleBook, type BibleBookIntro, type BibleChapter, BibleClient, type BibleIndex, type BibleIndexBook, type BibleIndexChapter, type BibleIndexVerse, type BiblePassage, type BibleVerse, type BibleVersion, type CANON, type Collection, type CreateHighlight, DEFAULT_LICENSE_FREE_BIBLE_VERSION, type DeleteHighlightOptions, type GetHighlightsOptions, type GetLanguagesOptions, type Highlight, type HighlightColor, HighlightsClient, type Language, LanguagesClient, MemoryStorageStrategy, SessionStorageStrategy, SignInWithYouVersionPermission, type SignInWithYouVersionPermissionValues, SignInWithYouVersionResult, type StorageStrategy, type User, type VOTD, YouVersionAPI, YouVersionAPIUsers, YouVersionPlatformConfiguration, YouVersionUserInfo, type YouVersionUserInfoJSON, getAdjacentChapter };
|
|
742
|
+
export { ApiClient, type ApiConfig, type AuthenticationScopes, type AuthenticationState, BOOK_CANON, BOOK_IDS, type BibleBook, type BibleBookIntro, type BibleChapter, BibleClient, type BibleIndex, type BibleIndexBook, type BibleIndexChapter, type BibleIndexVerse, type BiblePassage, type BibleVerse, type BibleVersion, type CANON, CANON_IDS, type Collection, type CreateHighlight, DEFAULT_LICENSE_FREE_BIBLE_VERSION, type DeleteHighlightOptions, type GetHighlightsOptions, type GetLanguagesOptions, type Highlight, type HighlightColor, HighlightsClient, type Language, LanguagesClient, MemoryStorageStrategy, SessionStorageStrategy, SignInWithYouVersionPermission, type SignInWithYouVersionPermissionValues, SignInWithYouVersionResult, type StorageStrategy, type User, type VOTD, YouVersionAPI, YouVersionAPIUsers, YouVersionPlatformConfiguration, YouVersionUserInfo, type YouVersionUserInfoJSON, getAdjacentChapter };
|
package/dist/index.js
CHANGED
|
@@ -162,6 +162,7 @@ import { z as z3 } from "zod";
|
|
|
162
162
|
|
|
163
163
|
// src/utils/constants.ts
|
|
164
164
|
var DEFAULT_LICENSE_FREE_BIBLE_VERSION = 3034;
|
|
165
|
+
var CANON_IDS = ["old_testament", "new_testament", "deuterocanon"];
|
|
165
166
|
var BOOK_IDS = [
|
|
166
167
|
"GEN",
|
|
167
168
|
"EXO",
|
|
@@ -403,7 +404,7 @@ var BibleChapterSchema = z2.object({
|
|
|
403
404
|
});
|
|
404
405
|
|
|
405
406
|
// src/schemas/book.ts
|
|
406
|
-
var CanonSchema = z3.enum(
|
|
407
|
+
var CanonSchema = z3.enum(CANON_IDS);
|
|
407
408
|
var BibleBookIntroSchema = z3.object({
|
|
408
409
|
/** Intro identifier */
|
|
409
410
|
id: z3.string(),
|
|
@@ -1694,6 +1695,7 @@ export {
|
|
|
1694
1695
|
BOOK_CANON,
|
|
1695
1696
|
BOOK_IDS,
|
|
1696
1697
|
BibleClient,
|
|
1698
|
+
CANON_IDS,
|
|
1697
1699
|
DEFAULT_LICENSE_FREE_BIBLE_VERSION,
|
|
1698
1700
|
HighlightsClient,
|
|
1699
1701
|
LanguagesClient,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@youversion/platform-core",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"tsup": "8.5.0",
|
|
31
31
|
"typescript": "5.9.3",
|
|
32
32
|
"vitest": "4.0.4",
|
|
33
|
-
"@internal/
|
|
34
|
-
"@internal/
|
|
33
|
+
"@internal/tsconfig": "0.0.0",
|
|
34
|
+
"@internal/eslint-config": "0.0.0"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"zod": "4.1.12"
|
package/src/schemas/book.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { BOOK_IDS } from '../utils/constants';
|
|
2
|
+
import { BOOK_IDS, CANON_IDS } from '../utils/constants';
|
|
3
3
|
import { BibleChapterSchema } from './chapter';
|
|
4
4
|
|
|
5
|
-
export const CanonSchema = z.enum(
|
|
6
|
-
export type Canon = Readonly<z.infer<typeof CanonSchema>>;
|
|
5
|
+
export const CanonSchema = z.enum(CANON_IDS);
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
const BibleBookIntroSchema = z.object({
|
|
9
8
|
/** Intro identifier */
|
|
10
9
|
id: z.string(),
|
|
11
10
|
/** Intro passage identifier */
|
|
@@ -20,7 +19,6 @@ export const BookUsfmSchema = z.union([
|
|
|
20
19
|
...BOOK_IDS.map((id) => z.literal(id)),
|
|
21
20
|
z.string().length(3) as z.ZodType<string & {}>,
|
|
22
21
|
]);
|
|
23
|
-
export type BookUsfm = z.infer<typeof BookUsfmSchema>;
|
|
24
22
|
|
|
25
23
|
export const BibleBookSchema = z.object({
|
|
26
24
|
/** Book identifier (e.g., "MAT") */
|
package/src/types/index.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
SignInWithYouVersionPermission,
|
|
3
|
+
SignInWithYouVersionResult,
|
|
4
|
+
} from '../SignInWithYouVersionResult';
|
|
5
|
+
|
|
1
6
|
// Re-export all schema-derived types from schemas
|
|
2
7
|
export type { BibleVersion } from '../schemas/version';
|
|
3
8
|
export type { BibleBook, BibleBookIntro, CANON } from '../schemas/book';
|
|
@@ -16,11 +21,30 @@ export type { User } from '../schemas/user';
|
|
|
16
21
|
export type { Highlight, CreateHighlight } from '../schemas/highlight';
|
|
17
22
|
export type { Collection } from '../schemas/collection';
|
|
18
23
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
24
|
+
export interface ApiConfig {
|
|
25
|
+
apiHost?: string;
|
|
26
|
+
appKey: string;
|
|
27
|
+
timeout?: number;
|
|
28
|
+
installationId?: string;
|
|
29
|
+
redirectUri?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type SignInWithYouVersionPermissionValues =
|
|
33
|
+
(typeof SignInWithYouVersionPermission)[keyof typeof SignInWithYouVersionPermission];
|
|
34
|
+
|
|
35
|
+
export interface AuthenticationState {
|
|
36
|
+
readonly isAuthenticated: boolean;
|
|
37
|
+
readonly isLoading: boolean;
|
|
38
|
+
readonly accessToken: string | null;
|
|
39
|
+
readonly idToken: string | null;
|
|
40
|
+
readonly result: SignInWithYouVersionResult | null;
|
|
41
|
+
readonly error: Error | null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export type AuthenticationScopes = 'profile' | 'email';
|
|
45
|
+
|
|
46
|
+
export interface HighlightColor {
|
|
47
|
+
id: number;
|
|
48
|
+
color: string;
|
|
49
|
+
label: string;
|
|
50
|
+
}
|
package/src/utils/constants.ts
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export const DEFAULT_LICENSE_FREE_BIBLE_VERSION = 3034 as const;
|
|
7
7
|
|
|
8
|
+
export const CANON_IDS = ['old_testament', 'new_testament', 'deuterocanon'] as const;
|
|
9
|
+
|
|
8
10
|
export const BOOK_IDS = [
|
|
9
11
|
'GEN',
|
|
10
12
|
'EXO',
|
|
@@ -113,13 +115,13 @@ export const BOOK_IDS = [
|
|
|
113
115
|
'LKA',
|
|
114
116
|
] as const;
|
|
115
117
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
+
type CanonId = (typeof CANON_IDS)[number];
|
|
119
|
+
type KnownBookUsfm = (typeof BOOK_IDS)[number];
|
|
118
120
|
|
|
119
121
|
/**
|
|
120
122
|
* @see https://github.com/youversion/usfm-references/blob/main/usfm_references/books.py
|
|
121
123
|
*/
|
|
122
|
-
export const BOOK_CANON: Record<
|
|
124
|
+
export const BOOK_CANON: Record<KnownBookUsfm, CanonId> = {
|
|
123
125
|
GEN: 'old_testament',
|
|
124
126
|
EXO: 'old_testament',
|
|
125
127
|
LEV: 'old_testament',
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { vi } from 'vitest';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Creates a mock YouVersionPlatformConfiguration for testing
|
|
5
|
-
* Maintains internal state for access tokens and configuration
|
|
6
|
-
*/
|
|
7
|
-
export const createMockPlatformConfiguration = (): {
|
|
8
|
-
accessToken: string | null;
|
|
9
|
-
idToken: string | null;
|
|
10
|
-
refreshToken: string | null;
|
|
11
|
-
appKey: string;
|
|
12
|
-
apiHost: string;
|
|
13
|
-
installationId: string | null;
|
|
14
|
-
expiryDate: Date | null;
|
|
15
|
-
clearAuthTokens: ReturnType<typeof vi.fn>;
|
|
16
|
-
saveAuthData: ReturnType<typeof vi.fn>;
|
|
17
|
-
} => {
|
|
18
|
-
const config = {
|
|
19
|
-
accessToken: null as string | null,
|
|
20
|
-
idToken: null as string | null,
|
|
21
|
-
refreshToken: null as string | null,
|
|
22
|
-
appKey: '',
|
|
23
|
-
apiHost: 'test-api.example.com',
|
|
24
|
-
installationId: null as string | null,
|
|
25
|
-
expiryDate: null as Date | null,
|
|
26
|
-
clearAuthTokens: vi.fn(function (this: typeof config) {
|
|
27
|
-
this.accessToken = null;
|
|
28
|
-
this.idToken = null;
|
|
29
|
-
this.refreshToken = null;
|
|
30
|
-
this.expiryDate = null;
|
|
31
|
-
}),
|
|
32
|
-
saveAuthData: vi.fn(function (
|
|
33
|
-
this: typeof config,
|
|
34
|
-
accessToken: string | null,
|
|
35
|
-
refreshToken: string | null,
|
|
36
|
-
idToken: string | null,
|
|
37
|
-
expiryDate?: Date | null,
|
|
38
|
-
) {
|
|
39
|
-
this.accessToken = accessToken;
|
|
40
|
-
this.refreshToken = refreshToken;
|
|
41
|
-
this.idToken = idToken;
|
|
42
|
-
if (expiryDate !== undefined) {
|
|
43
|
-
this.expiryDate = expiryDate;
|
|
44
|
-
}
|
|
45
|
-
}),
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
// Bind methods to maintain context
|
|
49
|
-
config.clearAuthTokens = config.clearAuthTokens.bind(config);
|
|
50
|
-
config.saveAuthData = config.saveAuthData.bind(config);
|
|
51
|
-
|
|
52
|
-
return config;
|
|
53
|
-
};
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { vi } from 'vitest';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Creates a mock JWT token for testing
|
|
5
|
-
* @param payload The JWT payload to encode
|
|
6
|
-
* @returns A mock JWT string with the format header.payload.signature
|
|
7
|
-
*/
|
|
8
|
-
export const createMockJWT = (payload: Record<string, unknown>): string => {
|
|
9
|
-
// Use a simple encoding for testing (not real base64)
|
|
10
|
-
const header = 'mockHeader';
|
|
11
|
-
const body = JSON.stringify(payload);
|
|
12
|
-
const signature = 'mock-signature';
|
|
13
|
-
return `${header}.${body}.${signature}`;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Creates a realistic-looking JWT token with proper base64url encoding
|
|
18
|
-
* @param payload The JWT payload
|
|
19
|
-
* @returns A properly formatted JWT token
|
|
20
|
-
*/
|
|
21
|
-
export const createRealisticJWT = (payload: Record<string, unknown>): string => {
|
|
22
|
-
const header = { alg: 'HS256', typ: 'JWT' };
|
|
23
|
-
|
|
24
|
-
// Simple base64url encoding for testing
|
|
25
|
-
const base64urlEncode = (str: string) => {
|
|
26
|
-
if (typeof btoa !== 'undefined') {
|
|
27
|
-
return btoa(str).replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_');
|
|
28
|
-
}
|
|
29
|
-
// Fallback for test environment
|
|
30
|
-
return Buffer.from(str)
|
|
31
|
-
.toString('base64')
|
|
32
|
-
.replace(/=/g, '')
|
|
33
|
-
.replace(/\+/g, '-')
|
|
34
|
-
.replace(/\//g, '_');
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const headerEncoded = base64urlEncode(JSON.stringify(header));
|
|
38
|
-
const payloadEncoded = base64urlEncode(JSON.stringify(payload));
|
|
39
|
-
const signature = 'invalid-signature'; // Mock signature
|
|
40
|
-
|
|
41
|
-
return `${headerEncoded}.${payloadEncoded}.${signature}`;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Sets up JWT-related mocks for atob/btoa functions
|
|
46
|
-
* @param payload The expected JWT payload to decode
|
|
47
|
-
*/
|
|
48
|
-
export const setupJWTMocks = (
|
|
49
|
-
payload: Record<string, unknown> = {},
|
|
50
|
-
): { atob: ReturnType<typeof vi.fn>; btoa: ReturnType<typeof vi.fn> } => {
|
|
51
|
-
const atobMock = vi.fn((str: string) => {
|
|
52
|
-
// Handle base64 padding
|
|
53
|
-
let padded = str;
|
|
54
|
-
while (padded.length % 4 !== 0) {
|
|
55
|
-
padded += '=';
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// For testing, just return the payload
|
|
59
|
-
if (str.includes('eyJ')) {
|
|
60
|
-
// Looks like a real base64 JWT part
|
|
61
|
-
return JSON.stringify(payload);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return str;
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
const btoaMock = vi.fn((str: string) => {
|
|
68
|
-
// Simple base64 encoding for testing
|
|
69
|
-
return `base64_${str.length}`;
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
vi.stubGlobal('atob', atobMock);
|
|
73
|
-
vi.stubGlobal('btoa', btoaMock);
|
|
74
|
-
|
|
75
|
-
return { atob: atobMock, btoa: btoaMock };
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Creates a mock JWT with standard claims
|
|
80
|
-
* @param overrides Optional claim overrides
|
|
81
|
-
*/
|
|
82
|
-
export const createMockJWTWithClaims = (overrides: Record<string, unknown> = {}): string => {
|
|
83
|
-
const defaultClaims = {
|
|
84
|
-
sub: '1234567890',
|
|
85
|
-
name: 'John Doe',
|
|
86
|
-
email: 'john@example.com',
|
|
87
|
-
profile_picture: 'https://example.com/avatar.jpg',
|
|
88
|
-
iat: 1516239022,
|
|
89
|
-
exp: 1516242622,
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
return createRealisticJWT({ ...defaultClaims, ...overrides });
|
|
93
|
-
};
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { vi } from 'vitest';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Creates a mock OAuth token response for testing
|
|
5
|
-
* @param overrides Optional properties to override the default values
|
|
6
|
-
*/
|
|
7
|
-
export const createMockTokenResponse = (
|
|
8
|
-
overrides: Record<string, unknown> = {},
|
|
9
|
-
): Record<string, unknown> => ({
|
|
10
|
-
access_token: 'access-token-123',
|
|
11
|
-
expires_in: 3600,
|
|
12
|
-
id_token:
|
|
13
|
-
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyLCJlbWFpbCI6ImpvaG5AZXhhbXBsZS5jb20iLCJwcm9maWxlX3BpY3R1cmUiOiJodHRwczovL2V4YW1wbGUuY29tL2F2YXRhci5qcGcifQ.invalid-signature',
|
|
14
|
-
refresh_token: 'refresh-token-456',
|
|
15
|
-
scope: 'bibles highlights openid',
|
|
16
|
-
token_type: 'Bearer',
|
|
17
|
-
...overrides,
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Creates a mock fetch response for testing
|
|
22
|
-
* @param data The response data
|
|
23
|
-
* @param options Optional properties to override the default response
|
|
24
|
-
*/
|
|
25
|
-
export const createMockFetchResponse = (
|
|
26
|
-
data: unknown,
|
|
27
|
-
options: Record<string, unknown> = {},
|
|
28
|
-
): Record<string, unknown> => ({
|
|
29
|
-
ok: true,
|
|
30
|
-
status: 200,
|
|
31
|
-
statusText: 'OK',
|
|
32
|
-
json: vi.fn().mockResolvedValue(data),
|
|
33
|
-
text: vi.fn().mockResolvedValue(JSON.stringify(data)),
|
|
34
|
-
clone: vi.fn(() => ({
|
|
35
|
-
text: vi.fn().mockResolvedValue(JSON.stringify(data)),
|
|
36
|
-
})),
|
|
37
|
-
...options,
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Creates a mock error fetch response for testing
|
|
42
|
-
* @param status The HTTP status code
|
|
43
|
-
* @param statusText The HTTP status text
|
|
44
|
-
*/
|
|
45
|
-
export const createMockErrorFetchResponse = (
|
|
46
|
-
status: number,
|
|
47
|
-
statusText: string,
|
|
48
|
-
): Record<string, unknown> => ({
|
|
49
|
-
ok: false,
|
|
50
|
-
status,
|
|
51
|
-
statusText,
|
|
52
|
-
json: vi.fn().mockRejectedValue(new Error('Response not JSON')),
|
|
53
|
-
text: vi.fn().mockResolvedValue(''),
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Creates a mock refresh token response for testing
|
|
58
|
-
* @param overrides Optional properties to override the default values
|
|
59
|
-
*/
|
|
60
|
-
export const createMockRefreshTokenResponse = (
|
|
61
|
-
overrides: Record<string, unknown> = {},
|
|
62
|
-
): Record<string, unknown> => ({
|
|
63
|
-
access_token: 'new-access-token',
|
|
64
|
-
expires_in: 3600,
|
|
65
|
-
refresh_token: 'new-refresh-token',
|
|
66
|
-
scope: 'bibles highlights openid',
|
|
67
|
-
token_type: 'Bearer',
|
|
68
|
-
...overrides,
|
|
69
|
-
});
|
package/src/highlight.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { HighlightColor } from './types';
|
|
2
|
-
|
|
3
|
-
export const HIGHLIGHT_COLORS: HighlightColor[] = [
|
|
4
|
-
{ id: 0, color: '#fffe00', label: 'Yellow' },
|
|
5
|
-
{ id: 1, color: '#5dff79', label: 'Green' },
|
|
6
|
-
{ id: 2, color: '#00d6ff', label: 'Blue' },
|
|
7
|
-
{ id: 3, color: '#ffc66f', label: 'Orange' },
|
|
8
|
-
{ id: 4, color: '#ff95ef', label: 'Pink' },
|
|
9
|
-
] as const;
|
|
10
|
-
|
|
11
|
-
export function hexToRgba(hex: string, alpha: number): string {
|
|
12
|
-
const r = parseInt(hex.slice(1, 3), 16);
|
|
13
|
-
const g = parseInt(hex.slice(3, 5), 16);
|
|
14
|
-
const b = parseInt(hex.slice(5, 7), 16);
|
|
15
|
-
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
|
|
16
|
-
}
|
package/src/types/api-config.ts
DELETED
package/src/types/auth.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
SignInWithYouVersionPermission,
|
|
3
|
-
SignInWithYouVersionResult,
|
|
4
|
-
} from '../SignInWithYouVersionResult';
|
|
5
|
-
|
|
6
|
-
export type SignInWithYouVersionPermissionValues =
|
|
7
|
-
(typeof SignInWithYouVersionPermission)[keyof typeof SignInWithYouVersionPermission];
|
|
8
|
-
|
|
9
|
-
export interface AuthenticationState {
|
|
10
|
-
readonly isAuthenticated: boolean;
|
|
11
|
-
readonly isLoading: boolean;
|
|
12
|
-
readonly accessToken: string | null;
|
|
13
|
-
readonly idToken: string | null;
|
|
14
|
-
readonly result: SignInWithYouVersionResult | null;
|
|
15
|
-
readonly error: Error | null;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export type AuthenticationScopes = 'profile' | 'email';
|