@youversion/platform-core 0.8.2 → 0.9.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/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +14 -0
- package/dist/index.cjs +116 -169
- package/dist/index.d.cts +19 -25
- package/dist/index.d.ts +19 -25
- package/dist/index.js +116 -168
- package/package.json +1 -1
- package/src/SignInWithYouVersionPKCE.ts +7 -7
- package/src/SignInWithYouVersionResult.ts +0 -6
- package/src/Users.ts +5 -29
- package/src/__tests__/MockBibles.ts +67 -67
- package/src/__tests__/SignInWithYouVersionPKCE.test.ts +8 -77
- package/src/__tests__/SignInWithYouVersionResult.test.ts +0 -2
- package/src/__tests__/Users.test.ts +4 -38
- package/src/__tests__/bible.test.ts +2 -2
- package/src/bible.ts +1 -1
- package/src/index.ts +0 -1
- package/src/schemas/book.ts +1 -5
- package/src/types/auth.ts +2 -0
- package/src/types/index.ts +5 -1
- package/src/utils/constants.ts +103 -103
- package/src/URLBuilder.ts +0 -50
- package/src/__tests__/URLBuilder.test.ts +0 -190
package/dist/index.d.ts
CHANGED
|
@@ -18,9 +18,9 @@ declare const BibleVersionSchema: z.ZodObject<{
|
|
|
18
18
|
type BibleVersion = z.infer<typeof BibleVersionSchema>;
|
|
19
19
|
|
|
20
20
|
declare const CanonSchema: z.ZodEnum<{
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
old_testament: "old_testament";
|
|
22
|
+
new_testament: "new_testament";
|
|
23
|
+
deuterocanon: "deuterocanon";
|
|
24
24
|
}>;
|
|
25
25
|
type Canon = z.infer<typeof CanonSchema>;
|
|
26
26
|
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>>]>;
|
|
@@ -31,9 +31,9 @@ declare const BibleBookSchema: z.ZodObject<{
|
|
|
31
31
|
full_title: z.ZodString;
|
|
32
32
|
abbreviation: z.ZodOptional<z.ZodString>;
|
|
33
33
|
canon: z.ZodEnum<{
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
old_testament: "old_testament";
|
|
35
|
+
new_testament: "new_testament";
|
|
36
|
+
deuterocanon: "deuterocanon";
|
|
37
37
|
}>;
|
|
38
38
|
chapters: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
39
39
|
id: z.ZodString;
|
|
@@ -101,9 +101,9 @@ declare const BibleIndexBookSchema: z.ZodObject<{
|
|
|
101
101
|
full_title: z.ZodString;
|
|
102
102
|
abbreviation: z.ZodString;
|
|
103
103
|
canon: z.ZodEnum<{
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
104
|
+
old_testament: "old_testament";
|
|
105
|
+
new_testament: "new_testament";
|
|
106
|
+
deuterocanon: "deuterocanon";
|
|
107
107
|
}>;
|
|
108
108
|
chapters: z.ZodArray<z.ZodObject<{
|
|
109
109
|
id: z.ZodString;
|
|
@@ -123,9 +123,9 @@ declare const _BibleIndexSchema: z.ZodObject<{
|
|
|
123
123
|
full_title: z.ZodString;
|
|
124
124
|
abbreviation: z.ZodString;
|
|
125
125
|
canon: z.ZodEnum<{
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
old_testament: "old_testament";
|
|
127
|
+
new_testament: "new_testament";
|
|
128
|
+
deuterocanon: "deuterocanon";
|
|
129
129
|
}>;
|
|
130
130
|
chapters: z.ZodArray<z.ZodObject<{
|
|
131
131
|
id: z.ZodString;
|
|
@@ -209,7 +209,6 @@ type SignInWithYouVersionResultProps = {
|
|
|
209
209
|
expiresIn?: number;
|
|
210
210
|
refreshToken?: string;
|
|
211
211
|
idToken?: string;
|
|
212
|
-
permissions?: SignInWithYouVersionPermissionValues[];
|
|
213
212
|
yvpUserId?: string;
|
|
214
213
|
name?: string;
|
|
215
214
|
profilePicture?: string;
|
|
@@ -220,12 +219,11 @@ declare class SignInWithYouVersionResult {
|
|
|
220
219
|
readonly expiryDate: Date | undefined;
|
|
221
220
|
readonly refreshToken: string | undefined;
|
|
222
221
|
readonly idToken: string | undefined;
|
|
223
|
-
readonly permissions: SignInWithYouVersionPermissionValues[] | undefined;
|
|
224
222
|
readonly yvpUserId: string | undefined;
|
|
225
223
|
readonly name: string | undefined;
|
|
226
224
|
readonly profilePicture: string | undefined;
|
|
227
225
|
readonly email: string | undefined;
|
|
228
|
-
constructor({ accessToken, expiresIn, refreshToken, idToken,
|
|
226
|
+
constructor({ accessToken, expiresIn, refreshToken, idToken, yvpUserId, name, profilePicture, email, }: SignInWithYouVersionResultProps);
|
|
229
227
|
}
|
|
230
228
|
|
|
231
229
|
type SignInWithYouVersionPermissionValues = (typeof SignInWithYouVersionPermission)[keyof typeof SignInWithYouVersionPermission];
|
|
@@ -237,6 +235,7 @@ interface AuthenticationState {
|
|
|
237
235
|
result: SignInWithYouVersionResult | null;
|
|
238
236
|
error: Error | null;
|
|
239
237
|
}
|
|
238
|
+
type AuthenticationScopes = 'profile' | 'email';
|
|
240
239
|
|
|
241
240
|
/**
|
|
242
241
|
* Legacy type for highlight colors (constants only)
|
|
@@ -337,7 +336,7 @@ declare class BibleClient {
|
|
|
337
336
|
/**
|
|
338
337
|
* Fetches all books for a given Bible version.
|
|
339
338
|
* @param versionId The version ID.
|
|
340
|
-
* @param canon Optional canon filter (
|
|
339
|
+
* @param canon Optional canon filter ("old_testament", 'new_testament', 'deuterocanon').
|
|
341
340
|
* @returns An array of BibleBook objects.
|
|
342
341
|
*/
|
|
343
342
|
getBooks(versionId: number, canon?: CANON): Promise<Collection<BibleBook>>;
|
|
@@ -593,14 +592,14 @@ declare class YouVersionAPIUsers {
|
|
|
593
592
|
/**
|
|
594
593
|
* Presents the YouVersion login flow to the user and returns the login result upon completion.
|
|
595
594
|
*
|
|
596
|
-
* This function authenticates the user with YouVersion
|
|
595
|
+
* This function authenticates the user with YouVersion.
|
|
597
596
|
* The function redirects to the YouVersion authorization URL and expects the callback to be handled separately.
|
|
598
597
|
*
|
|
599
|
-
* @param
|
|
598
|
+
* @param scopes - The scopes given to the authentication call.
|
|
600
599
|
* @param redirectURL - The URL to redirect back to after authentication.
|
|
601
600
|
* @throws An error if authentication fails or configuration is invalid.
|
|
602
601
|
*/
|
|
603
|
-
static signIn(
|
|
602
|
+
static signIn(redirectURL: string, scopes?: AuthenticationScopes[]): Promise<void>;
|
|
604
603
|
/**
|
|
605
604
|
* Handles the OAuth callback after user authentication.
|
|
606
605
|
*
|
|
@@ -668,11 +667,6 @@ declare class YouVersionAPI {
|
|
|
668
667
|
static addStandardHeaders(url: URL): Request;
|
|
669
668
|
}
|
|
670
669
|
|
|
671
|
-
declare class URLBuilder {
|
|
672
|
-
private static get baseURL();
|
|
673
|
-
static authURL(appKey: string, requiredPermissions?: Set<SignInWithYouVersionPermissionValues>, optionalPermissions?: Set<SignInWithYouVersionPermissionValues>): URL;
|
|
674
|
-
}
|
|
675
|
-
|
|
676
670
|
/**
|
|
677
671
|
* Security Note: Tokens are stored in localStorage for persistence.
|
|
678
672
|
* Ensure your application follows XSS prevention best practices:
|
|
@@ -712,4 +706,4 @@ declare const BOOK_IDS: readonly ["GEN", "EXO", "LEV", "NUM", "DEU", "JOS", "JDG
|
|
|
712
706
|
*/
|
|
713
707
|
declare const BOOK_CANON: Record<BookUsfm, Canon>;
|
|
714
708
|
|
|
715
|
-
export { ApiClient, type ApiConfig, type AuthenticationState, 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,
|
|
709
|
+
export { ApiClient, type ApiConfig, type AuthenticationScopes, type AuthenticationState, 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, type User, type VOTD, YouVersionAPI, YouVersionAPIUsers, YouVersionPlatformConfiguration, YouVersionUserInfo, type YouVersionUserInfoJSON };
|
package/dist/index.js
CHANGED
|
@@ -192,7 +192,7 @@ var BibleClient = class {
|
|
|
192
192
|
/**
|
|
193
193
|
* Fetches all books for a given Bible version.
|
|
194
194
|
* @param versionId The version ID.
|
|
195
|
-
* @param canon Optional canon filter (
|
|
195
|
+
* @param canon Optional canon filter ("old_testament", 'new_testament', 'deuterocanon').
|
|
196
196
|
* @returns An array of BibleBook objects.
|
|
197
197
|
*/
|
|
198
198
|
async getBooks(versionId, canon) {
|
|
@@ -692,7 +692,7 @@ var YouVersionUserInfo = class {
|
|
|
692
692
|
|
|
693
693
|
// src/SignInWithYouVersionPKCE.ts
|
|
694
694
|
var SignInWithYouVersionPKCEAuthorizationRequestBuilder = class {
|
|
695
|
-
static async make(appKey,
|
|
695
|
+
static async make(appKey, redirectURL, scopes) {
|
|
696
696
|
const codeVerifier = this.randomURLSafeString(32);
|
|
697
697
|
const codeChallenge = await this.codeChallenge(codeVerifier);
|
|
698
698
|
const state = this.randomURLSafeString(24);
|
|
@@ -703,10 +703,10 @@ var SignInWithYouVersionPKCEAuthorizationRequestBuilder = class {
|
|
|
703
703
|
state,
|
|
704
704
|
nonce
|
|
705
705
|
};
|
|
706
|
-
const url = this.authorizeURL(appKey,
|
|
706
|
+
const url = this.authorizeURL(appKey, redirectURL, parameters, scopes);
|
|
707
707
|
return { url, parameters };
|
|
708
708
|
}
|
|
709
|
-
static authorizeURL(appKey,
|
|
709
|
+
static authorizeURL(appKey, redirectURL, parameters, scopes) {
|
|
710
710
|
const components = new URL(`https://${YouVersionPlatformConfiguration.apiHost}/auth/authorize`);
|
|
711
711
|
const redirectUrlString = redirectURL.toString().endsWith("/") ? redirectURL.toString().slice(0, -1) : redirectURL.toString();
|
|
712
712
|
const queryParams = new URLSearchParams({
|
|
@@ -722,7 +722,7 @@ var SignInWithYouVersionPKCEAuthorizationRequestBuilder = class {
|
|
|
722
722
|
if (installId) {
|
|
723
723
|
queryParams.set("x-yvp-installation-id", installId);
|
|
724
724
|
}
|
|
725
|
-
const scopeValue = this.scopeValue(
|
|
725
|
+
const scopeValue = this.scopeValue(scopes || []);
|
|
726
726
|
if (scopeValue) {
|
|
727
727
|
queryParams.set("scope", scopeValue);
|
|
728
728
|
}
|
|
@@ -762,8 +762,8 @@ var SignInWithYouVersionPKCEAuthorizationRequestBuilder = class {
|
|
|
762
762
|
const base64 = btoa(String.fromCharCode.apply(null, Array.from(data)));
|
|
763
763
|
return base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
764
764
|
}
|
|
765
|
-
static scopeValue(
|
|
766
|
-
const scopeArray = Array.from(
|
|
765
|
+
static scopeValue(scopes) {
|
|
766
|
+
const scopeArray = Array.from(scopes).sort();
|
|
767
767
|
let scopeWithOpenID = scopeArray.join(" ");
|
|
768
768
|
if (!scopeWithOpenID.split(" ").includes("openid")) {
|
|
769
769
|
scopeWithOpenID += (scopeWithOpenID === "" ? "" : " ") + "openid";
|
|
@@ -785,7 +785,6 @@ var SignInWithYouVersionResult = class {
|
|
|
785
785
|
expiryDate;
|
|
786
786
|
refreshToken;
|
|
787
787
|
idToken;
|
|
788
|
-
permissions;
|
|
789
788
|
yvpUserId;
|
|
790
789
|
name;
|
|
791
790
|
profilePicture;
|
|
@@ -795,7 +794,6 @@ var SignInWithYouVersionResult = class {
|
|
|
795
794
|
expiresIn,
|
|
796
795
|
refreshToken,
|
|
797
796
|
idToken,
|
|
798
|
-
permissions,
|
|
799
797
|
yvpUserId,
|
|
800
798
|
name,
|
|
801
799
|
profilePicture,
|
|
@@ -805,7 +803,6 @@ var SignInWithYouVersionResult = class {
|
|
|
805
803
|
this.expiryDate = expiresIn ? new Date(Date.now() + expiresIn * 1e3) : /* @__PURE__ */ new Date();
|
|
806
804
|
this.refreshToken = refreshToken;
|
|
807
805
|
this.idToken = idToken;
|
|
808
|
-
this.permissions = permissions;
|
|
809
806
|
this.yvpUserId = yvpUserId;
|
|
810
807
|
this.name = name;
|
|
811
808
|
this.profilePicture = profilePicture;
|
|
@@ -818,22 +815,22 @@ var YouVersionAPIUsers = class {
|
|
|
818
815
|
/**
|
|
819
816
|
* Presents the YouVersion login flow to the user and returns the login result upon completion.
|
|
820
817
|
*
|
|
821
|
-
* This function authenticates the user with YouVersion
|
|
818
|
+
* This function authenticates the user with YouVersion.
|
|
822
819
|
* The function redirects to the YouVersion authorization URL and expects the callback to be handled separately.
|
|
823
820
|
*
|
|
824
|
-
* @param
|
|
821
|
+
* @param scopes - The scopes given to the authentication call.
|
|
825
822
|
* @param redirectURL - The URL to redirect back to after authentication.
|
|
826
823
|
* @throws An error if authentication fails or configuration is invalid.
|
|
827
824
|
*/
|
|
828
|
-
static async signIn(
|
|
825
|
+
static async signIn(redirectURL, scopes) {
|
|
829
826
|
const appKey = YouVersionPlatformConfiguration.appKey;
|
|
830
827
|
if (!appKey) {
|
|
831
828
|
throw new Error("YouVersionPlatformConfiguration.appKey must be set before calling signIn");
|
|
832
829
|
}
|
|
833
830
|
const authorizationRequest = await SignInWithYouVersionPKCEAuthorizationRequestBuilder.make(
|
|
834
831
|
appKey,
|
|
835
|
-
|
|
836
|
-
|
|
832
|
+
new URL(redirectURL),
|
|
833
|
+
scopes
|
|
837
834
|
);
|
|
838
835
|
localStorage.setItem(
|
|
839
836
|
"youversion-auth-code-verifier",
|
|
@@ -933,17 +930,11 @@ var YouVersionAPIUsers = class {
|
|
|
933
930
|
*/
|
|
934
931
|
static extractSignInResult(tokens) {
|
|
935
932
|
const idClaims = this.decodeJWT(tokens.id_token);
|
|
936
|
-
const permissions = tokens.scope.split(" ").map((p) => p.trim()).filter((p) => p.length > 0).filter(
|
|
937
|
-
(p) => Object.values(SignInWithYouVersionPermission).includes(
|
|
938
|
-
p
|
|
939
|
-
)
|
|
940
|
-
);
|
|
941
933
|
const resultData = {
|
|
942
934
|
accessToken: tokens.access_token,
|
|
943
935
|
expiresIn: tokens.expires_in,
|
|
944
936
|
refreshToken: tokens.refresh_token,
|
|
945
937
|
idToken: tokens.id_token,
|
|
946
|
-
permissions,
|
|
947
938
|
yvpUserId: idClaims.sub,
|
|
948
939
|
name: idClaims.name,
|
|
949
940
|
profilePicture: idClaims.profile_picture,
|
|
@@ -1062,12 +1053,7 @@ var YouVersionAPIUsers = class {
|
|
|
1062
1053
|
accessToken: tokens.access_token,
|
|
1063
1054
|
expiresIn: tokens.expires_in,
|
|
1064
1055
|
refreshToken: tokens.refresh_token,
|
|
1065
|
-
idToken: existingIdToken
|
|
1066
|
-
permissions: tokens.scope.split(" ").map((p) => p.trim()).filter((p) => p.length > 0).filter(
|
|
1067
|
-
(p) => Object.values(SignInWithYouVersionPermission).includes(
|
|
1068
|
-
p
|
|
1069
|
-
)
|
|
1070
|
-
)
|
|
1056
|
+
idToken: existingIdToken
|
|
1071
1057
|
});
|
|
1072
1058
|
YouVersionPlatformConfiguration.saveAuthData(
|
|
1073
1059
|
result.accessToken || null,
|
|
@@ -1137,43 +1123,6 @@ var YouVersionAPI = class {
|
|
|
1137
1123
|
}
|
|
1138
1124
|
};
|
|
1139
1125
|
|
|
1140
|
-
// src/URLBuilder.ts
|
|
1141
|
-
var URLBuilder = class {
|
|
1142
|
-
static get baseURL() {
|
|
1143
|
-
return new URL(`https://${YouVersionPlatformConfiguration.apiHost}`);
|
|
1144
|
-
}
|
|
1145
|
-
static authURL(appKey, requiredPermissions = /* @__PURE__ */ new Set(), optionalPermissions = /* @__PURE__ */ new Set()) {
|
|
1146
|
-
if (typeof appKey !== "string" || appKey.trim().length === 0) {
|
|
1147
|
-
throw new Error("appKey must be a non-empty string");
|
|
1148
|
-
}
|
|
1149
|
-
try {
|
|
1150
|
-
const url = new URL(this.baseURL);
|
|
1151
|
-
url.pathname = "/auth/login";
|
|
1152
|
-
const searchParams = new URLSearchParams();
|
|
1153
|
-
searchParams.append("APP_KEY", appKey);
|
|
1154
|
-
searchParams.append("language", "en");
|
|
1155
|
-
if (requiredPermissions.size > 0) {
|
|
1156
|
-
const requiredList = Array.from(requiredPermissions).map((p) => p.toString());
|
|
1157
|
-
searchParams.append("required_perms", requiredList.join(","));
|
|
1158
|
-
}
|
|
1159
|
-
if (optionalPermissions.size > 0) {
|
|
1160
|
-
const optionalList = Array.from(optionalPermissions).map((p) => p.toString());
|
|
1161
|
-
searchParams.append("opt_perms", optionalList.join(","));
|
|
1162
|
-
}
|
|
1163
|
-
const installationId = YouVersionPlatformConfiguration.installationId;
|
|
1164
|
-
if (installationId) {
|
|
1165
|
-
searchParams.append("x-yvp-installation-id", installationId);
|
|
1166
|
-
}
|
|
1167
|
-
url.search = searchParams.toString();
|
|
1168
|
-
return url;
|
|
1169
|
-
} catch (error) {
|
|
1170
|
-
throw new Error(
|
|
1171
|
-
`Failed to construct auth URL: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
1172
|
-
);
|
|
1173
|
-
}
|
|
1174
|
-
}
|
|
1175
|
-
};
|
|
1176
|
-
|
|
1177
1126
|
// src/utils/constants.ts
|
|
1178
1127
|
var BOOK_IDS = [
|
|
1179
1128
|
"GEN",
|
|
@@ -1283,109 +1232,109 @@ var BOOK_IDS = [
|
|
|
1283
1232
|
"LKA"
|
|
1284
1233
|
];
|
|
1285
1234
|
var BOOK_CANON = {
|
|
1286
|
-
GEN: "
|
|
1287
|
-
EXO: "
|
|
1288
|
-
LEV: "
|
|
1289
|
-
NUM: "
|
|
1290
|
-
DEU: "
|
|
1291
|
-
JOS: "
|
|
1292
|
-
JDG: "
|
|
1293
|
-
RUT: "
|
|
1294
|
-
"1SA": "
|
|
1295
|
-
"2SA": "
|
|
1296
|
-
"1KI": "
|
|
1297
|
-
"2KI": "
|
|
1298
|
-
"1CH": "
|
|
1299
|
-
"2CH": "
|
|
1300
|
-
EZR: "
|
|
1301
|
-
NEH: "
|
|
1302
|
-
EST: "
|
|
1303
|
-
JOB: "
|
|
1304
|
-
PSA: "
|
|
1305
|
-
PRO: "
|
|
1306
|
-
ECC: "
|
|
1307
|
-
SNG: "
|
|
1308
|
-
ISA: "
|
|
1309
|
-
JER: "
|
|
1310
|
-
LAM: "
|
|
1311
|
-
EZK: "
|
|
1312
|
-
DAN: "
|
|
1313
|
-
HOS: "
|
|
1314
|
-
JOL: "
|
|
1315
|
-
AMO: "
|
|
1316
|
-
OBA: "
|
|
1317
|
-
JON: "
|
|
1318
|
-
MIC: "
|
|
1319
|
-
NAM: "
|
|
1320
|
-
HAB: "
|
|
1321
|
-
ZEP: "
|
|
1322
|
-
HAG: "
|
|
1323
|
-
ZEC: "
|
|
1324
|
-
MAL: "
|
|
1325
|
-
MAT: "
|
|
1326
|
-
MRK: "
|
|
1327
|
-
LUK: "
|
|
1328
|
-
JHN: "
|
|
1329
|
-
ACT: "
|
|
1330
|
-
ROM: "
|
|
1331
|
-
"1CO": "
|
|
1332
|
-
"2CO": "
|
|
1333
|
-
GAL: "
|
|
1334
|
-
EPH: "
|
|
1335
|
-
PHP: "
|
|
1336
|
-
COL: "
|
|
1337
|
-
"1TH": "
|
|
1338
|
-
"2TH": "
|
|
1339
|
-
"1TI": "
|
|
1340
|
-
"2TI": "
|
|
1341
|
-
TIT: "
|
|
1342
|
-
PHM: "
|
|
1343
|
-
HEB: "
|
|
1344
|
-
JAS: "
|
|
1345
|
-
"1PE": "
|
|
1346
|
-
"2PE": "
|
|
1347
|
-
"1JN": "
|
|
1348
|
-
"2JN": "
|
|
1349
|
-
"3JN": "
|
|
1350
|
-
JUD: "
|
|
1351
|
-
REV: "
|
|
1352
|
-
TOB: "
|
|
1353
|
-
JDT: "
|
|
1354
|
-
ESG: "
|
|
1355
|
-
WIS: "
|
|
1356
|
-
SIR: "
|
|
1357
|
-
BAR: "
|
|
1358
|
-
LJE: "
|
|
1359
|
-
S3Y: "
|
|
1360
|
-
SUS: "
|
|
1361
|
-
BEL: "
|
|
1362
|
-
"1MA": "
|
|
1363
|
-
"2MA": "
|
|
1364
|
-
"3MA": "
|
|
1365
|
-
"4MA": "
|
|
1366
|
-
"1ES": "
|
|
1367
|
-
"2ES": "
|
|
1368
|
-
MAN: "
|
|
1369
|
-
PS2: "
|
|
1370
|
-
ODA: "
|
|
1371
|
-
PSS: "
|
|
1372
|
-
"3ES": "
|
|
1373
|
-
EZA: "
|
|
1374
|
-
"5EZ": "
|
|
1375
|
-
"6EZ": "
|
|
1376
|
-
DAG: "
|
|
1377
|
-
PS3: "
|
|
1378
|
-
"2BA": "
|
|
1379
|
-
LBA: "
|
|
1380
|
-
JUB: "
|
|
1381
|
-
ENO: "
|
|
1382
|
-
"1MQ": "
|
|
1383
|
-
"2MQ": "
|
|
1384
|
-
"3MQ": "
|
|
1385
|
-
REP: "
|
|
1386
|
-
"4BA": "
|
|
1387
|
-
LAO: "
|
|
1388
|
-
LKA: "
|
|
1235
|
+
GEN: "old_testament",
|
|
1236
|
+
EXO: "old_testament",
|
|
1237
|
+
LEV: "old_testament",
|
|
1238
|
+
NUM: "old_testament",
|
|
1239
|
+
DEU: "old_testament",
|
|
1240
|
+
JOS: "old_testament",
|
|
1241
|
+
JDG: "old_testament",
|
|
1242
|
+
RUT: "old_testament",
|
|
1243
|
+
"1SA": "old_testament",
|
|
1244
|
+
"2SA": "old_testament",
|
|
1245
|
+
"1KI": "old_testament",
|
|
1246
|
+
"2KI": "old_testament",
|
|
1247
|
+
"1CH": "old_testament",
|
|
1248
|
+
"2CH": "old_testament",
|
|
1249
|
+
EZR: "old_testament",
|
|
1250
|
+
NEH: "old_testament",
|
|
1251
|
+
EST: "old_testament",
|
|
1252
|
+
JOB: "old_testament",
|
|
1253
|
+
PSA: "old_testament",
|
|
1254
|
+
PRO: "old_testament",
|
|
1255
|
+
ECC: "old_testament",
|
|
1256
|
+
SNG: "old_testament",
|
|
1257
|
+
ISA: "old_testament",
|
|
1258
|
+
JER: "old_testament",
|
|
1259
|
+
LAM: "old_testament",
|
|
1260
|
+
EZK: "old_testament",
|
|
1261
|
+
DAN: "old_testament",
|
|
1262
|
+
HOS: "old_testament",
|
|
1263
|
+
JOL: "old_testament",
|
|
1264
|
+
AMO: "old_testament",
|
|
1265
|
+
OBA: "old_testament",
|
|
1266
|
+
JON: "old_testament",
|
|
1267
|
+
MIC: "old_testament",
|
|
1268
|
+
NAM: "old_testament",
|
|
1269
|
+
HAB: "old_testament",
|
|
1270
|
+
ZEP: "old_testament",
|
|
1271
|
+
HAG: "old_testament",
|
|
1272
|
+
ZEC: "old_testament",
|
|
1273
|
+
MAL: "old_testament",
|
|
1274
|
+
MAT: "new_testament",
|
|
1275
|
+
MRK: "new_testament",
|
|
1276
|
+
LUK: "new_testament",
|
|
1277
|
+
JHN: "new_testament",
|
|
1278
|
+
ACT: "new_testament",
|
|
1279
|
+
ROM: "new_testament",
|
|
1280
|
+
"1CO": "new_testament",
|
|
1281
|
+
"2CO": "new_testament",
|
|
1282
|
+
GAL: "new_testament",
|
|
1283
|
+
EPH: "new_testament",
|
|
1284
|
+
PHP: "new_testament",
|
|
1285
|
+
COL: "new_testament",
|
|
1286
|
+
"1TH": "new_testament",
|
|
1287
|
+
"2TH": "new_testament",
|
|
1288
|
+
"1TI": "new_testament",
|
|
1289
|
+
"2TI": "new_testament",
|
|
1290
|
+
TIT: "new_testament",
|
|
1291
|
+
PHM: "new_testament",
|
|
1292
|
+
HEB: "new_testament",
|
|
1293
|
+
JAS: "new_testament",
|
|
1294
|
+
"1PE": "new_testament",
|
|
1295
|
+
"2PE": "new_testament",
|
|
1296
|
+
"1JN": "new_testament",
|
|
1297
|
+
"2JN": "new_testament",
|
|
1298
|
+
"3JN": "new_testament",
|
|
1299
|
+
JUD: "new_testament",
|
|
1300
|
+
REV: "new_testament",
|
|
1301
|
+
TOB: "deuterocanon",
|
|
1302
|
+
JDT: "deuterocanon",
|
|
1303
|
+
ESG: "deuterocanon",
|
|
1304
|
+
WIS: "deuterocanon",
|
|
1305
|
+
SIR: "deuterocanon",
|
|
1306
|
+
BAR: "deuterocanon",
|
|
1307
|
+
LJE: "deuterocanon",
|
|
1308
|
+
S3Y: "deuterocanon",
|
|
1309
|
+
SUS: "deuterocanon",
|
|
1310
|
+
BEL: "deuterocanon",
|
|
1311
|
+
"1MA": "deuterocanon",
|
|
1312
|
+
"2MA": "deuterocanon",
|
|
1313
|
+
"3MA": "deuterocanon",
|
|
1314
|
+
"4MA": "deuterocanon",
|
|
1315
|
+
"1ES": "deuterocanon",
|
|
1316
|
+
"2ES": "deuterocanon",
|
|
1317
|
+
MAN: "deuterocanon",
|
|
1318
|
+
PS2: "deuterocanon",
|
|
1319
|
+
ODA: "deuterocanon",
|
|
1320
|
+
PSS: "deuterocanon",
|
|
1321
|
+
"3ES": "deuterocanon",
|
|
1322
|
+
EZA: "deuterocanon",
|
|
1323
|
+
"5EZ": "deuterocanon",
|
|
1324
|
+
"6EZ": "deuterocanon",
|
|
1325
|
+
DAG: "deuterocanon",
|
|
1326
|
+
PS3: "deuterocanon",
|
|
1327
|
+
"2BA": "deuterocanon",
|
|
1328
|
+
LBA: "deuterocanon",
|
|
1329
|
+
JUB: "deuterocanon",
|
|
1330
|
+
ENO: "deuterocanon",
|
|
1331
|
+
"1MQ": "deuterocanon",
|
|
1332
|
+
"2MQ": "deuterocanon",
|
|
1333
|
+
"3MQ": "deuterocanon",
|
|
1334
|
+
REP: "deuterocanon",
|
|
1335
|
+
"4BA": "deuterocanon",
|
|
1336
|
+
LAO: "deuterocanon",
|
|
1337
|
+
LKA: "new_testament"
|
|
1389
1338
|
// Luke-Acts combo, treated canonically as New Testament
|
|
1390
1339
|
};
|
|
1391
1340
|
export {
|
|
@@ -1399,7 +1348,6 @@ export {
|
|
|
1399
1348
|
SessionStorageStrategy,
|
|
1400
1349
|
SignInWithYouVersionPermission,
|
|
1401
1350
|
SignInWithYouVersionResult,
|
|
1402
|
-
URLBuilder,
|
|
1403
1351
|
YouVersionAPI,
|
|
1404
1352
|
YouVersionAPIUsers,
|
|
1405
1353
|
YouVersionPlatformConfiguration,
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { YouVersionPlatformConfiguration } from './YouVersionPlatformConfiguration';
|
|
2
|
-
import type {
|
|
2
|
+
import type { AuthenticationScopes } from './types';
|
|
3
3
|
|
|
4
4
|
type SignInWithYouVersionPKCEParameters = {
|
|
5
5
|
readonly codeVerifier: string;
|
|
@@ -15,8 +15,8 @@ type SignInWithYouVersionPKCEAuthorizationRequest = {
|
|
|
15
15
|
export class SignInWithYouVersionPKCEAuthorizationRequestBuilder {
|
|
16
16
|
public static async make(
|
|
17
17
|
appKey: string,
|
|
18
|
-
permissions: Set<SignInWithYouVersionPermissionValues>,
|
|
19
18
|
redirectURL: URL,
|
|
19
|
+
scopes?: AuthenticationScopes[],
|
|
20
20
|
): Promise<SignInWithYouVersionPKCEAuthorizationRequest> {
|
|
21
21
|
const codeVerifier = this.randomURLSafeString(32);
|
|
22
22
|
const codeChallenge = await this.codeChallenge(codeVerifier);
|
|
@@ -30,16 +30,16 @@ export class SignInWithYouVersionPKCEAuthorizationRequestBuilder {
|
|
|
30
30
|
nonce,
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
-
const url = this.authorizeURL(appKey,
|
|
33
|
+
const url = this.authorizeURL(appKey, redirectURL, parameters, scopes);
|
|
34
34
|
|
|
35
35
|
return { url, parameters };
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
private static authorizeURL(
|
|
39
39
|
appKey: string,
|
|
40
|
-
permissions: Set<SignInWithYouVersionPermissionValues>,
|
|
41
40
|
redirectURL: URL,
|
|
42
41
|
parameters: SignInWithYouVersionPKCEParameters,
|
|
42
|
+
scopes?: AuthenticationScopes[],
|
|
43
43
|
): URL {
|
|
44
44
|
const components = new URL(`https://${YouVersionPlatformConfiguration.apiHost}/auth/authorize`);
|
|
45
45
|
|
|
@@ -61,7 +61,7 @@ export class SignInWithYouVersionPKCEAuthorizationRequestBuilder {
|
|
|
61
61
|
queryParams.set('x-yvp-installation-id', installId);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
const scopeValue = this.scopeValue(
|
|
64
|
+
const scopeValue = this.scopeValue(scopes || []);
|
|
65
65
|
if (scopeValue) {
|
|
66
66
|
queryParams.set('scope', scopeValue);
|
|
67
67
|
}
|
|
@@ -109,8 +109,8 @@ export class SignInWithYouVersionPKCEAuthorizationRequestBuilder {
|
|
|
109
109
|
return base64.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
private static scopeValue(
|
|
113
|
-
const scopeArray = Array.from(
|
|
112
|
+
private static scopeValue(scopes: AuthenticationScopes[]): string | null {
|
|
113
|
+
const scopeArray = Array.from(scopes).sort();
|
|
114
114
|
let scopeWithOpenID = scopeArray.join(' ');
|
|
115
115
|
|
|
116
116
|
if (!scopeWithOpenID.split(' ').includes('openid')) {
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { SignInWithYouVersionPermissionValues } from './types';
|
|
2
|
-
|
|
3
1
|
export const SignInWithYouVersionPermission = {
|
|
4
2
|
bibles: 'bibles',
|
|
5
3
|
highlights: 'highlights',
|
|
@@ -13,7 +11,6 @@ type SignInWithYouVersionResultProps = {
|
|
|
13
11
|
expiresIn?: number;
|
|
14
12
|
refreshToken?: string;
|
|
15
13
|
idToken?: string;
|
|
16
|
-
permissions?: SignInWithYouVersionPermissionValues[];
|
|
17
14
|
yvpUserId?: string;
|
|
18
15
|
name?: string;
|
|
19
16
|
profilePicture?: string;
|
|
@@ -24,7 +21,6 @@ export class SignInWithYouVersionResult {
|
|
|
24
21
|
public readonly expiryDate: Date | undefined;
|
|
25
22
|
public readonly refreshToken: string | undefined;
|
|
26
23
|
public readonly idToken: string | undefined;
|
|
27
|
-
public readonly permissions: SignInWithYouVersionPermissionValues[] | undefined;
|
|
28
24
|
public readonly yvpUserId: string | undefined;
|
|
29
25
|
public readonly name: string | undefined;
|
|
30
26
|
public readonly profilePicture: string | undefined;
|
|
@@ -35,7 +31,6 @@ export class SignInWithYouVersionResult {
|
|
|
35
31
|
expiresIn,
|
|
36
32
|
refreshToken,
|
|
37
33
|
idToken,
|
|
38
|
-
permissions,
|
|
39
34
|
yvpUserId,
|
|
40
35
|
name,
|
|
41
36
|
profilePicture,
|
|
@@ -45,7 +40,6 @@ export class SignInWithYouVersionResult {
|
|
|
45
40
|
this.expiryDate = expiresIn ? new Date(Date.now() + expiresIn * 1000) : new Date();
|
|
46
41
|
this.refreshToken = refreshToken;
|
|
47
42
|
this.idToken = idToken;
|
|
48
|
-
this.permissions = permissions;
|
|
49
43
|
this.yvpUserId = yvpUserId;
|
|
50
44
|
this.name = name;
|
|
51
45
|
this.profilePicture = profilePicture;
|