@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/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
- ot: "ot";
22
- nt: "nt";
23
- dc: "dc";
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
- ot: "ot";
35
- nt: "nt";
36
- dc: "dc";
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
- ot: "ot";
105
- nt: "nt";
106
- dc: "dc";
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
- ot: "ot";
127
- nt: "nt";
128
- dc: "dc";
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, permissions, yvpUserId, name, profilePicture, email, }: SignInWithYouVersionResultProps);
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 ('ot', 'nt', 'deuterocanon').
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, requesting the specified required and optional permissions.
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 permissions - The set of permissions that must be granted by the user for successful login.
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(permissions: Set<SignInWithYouVersionPermissionValues>, redirectURL: string): Promise<void>;
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, URLBuilder, type User, type VOTD, YouVersionAPI, YouVersionAPIUsers, YouVersionPlatformConfiguration, YouVersionUserInfo, type YouVersionUserInfoJSON };
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 ('ot', 'nt', 'deuterocanon').
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, permissions, redirectURL) {
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, permissions, redirectURL, parameters);
706
+ const url = this.authorizeURL(appKey, redirectURL, parameters, scopes);
707
707
  return { url, parameters };
708
708
  }
709
- static authorizeURL(appKey, permissions, redirectURL, parameters) {
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(permissions);
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(permissions) {
766
- const scopeArray = Array.from(permissions).sort();
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, requesting the specified required and optional permissions.
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 permissions - The set of permissions that must be granted by the user for successful login.
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(permissions, redirectURL) {
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
- permissions,
836
- new URL(redirectURL)
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: "ot",
1287
- EXO: "ot",
1288
- LEV: "ot",
1289
- NUM: "ot",
1290
- DEU: "ot",
1291
- JOS: "ot",
1292
- JDG: "ot",
1293
- RUT: "ot",
1294
- "1SA": "ot",
1295
- "2SA": "ot",
1296
- "1KI": "ot",
1297
- "2KI": "ot",
1298
- "1CH": "ot",
1299
- "2CH": "ot",
1300
- EZR: "ot",
1301
- NEH: "ot",
1302
- EST: "ot",
1303
- JOB: "ot",
1304
- PSA: "ot",
1305
- PRO: "ot",
1306
- ECC: "ot",
1307
- SNG: "ot",
1308
- ISA: "ot",
1309
- JER: "ot",
1310
- LAM: "ot",
1311
- EZK: "ot",
1312
- DAN: "ot",
1313
- HOS: "ot",
1314
- JOL: "ot",
1315
- AMO: "ot",
1316
- OBA: "ot",
1317
- JON: "ot",
1318
- MIC: "ot",
1319
- NAM: "ot",
1320
- HAB: "ot",
1321
- ZEP: "ot",
1322
- HAG: "ot",
1323
- ZEC: "ot",
1324
- MAL: "ot",
1325
- MAT: "nt",
1326
- MRK: "nt",
1327
- LUK: "nt",
1328
- JHN: "nt",
1329
- ACT: "nt",
1330
- ROM: "nt",
1331
- "1CO": "nt",
1332
- "2CO": "nt",
1333
- GAL: "nt",
1334
- EPH: "nt",
1335
- PHP: "nt",
1336
- COL: "nt",
1337
- "1TH": "nt",
1338
- "2TH": "nt",
1339
- "1TI": "nt",
1340
- "2TI": "nt",
1341
- TIT: "nt",
1342
- PHM: "nt",
1343
- HEB: "nt",
1344
- JAS: "nt",
1345
- "1PE": "nt",
1346
- "2PE": "nt",
1347
- "1JN": "nt",
1348
- "2JN": "nt",
1349
- "3JN": "nt",
1350
- JUD: "nt",
1351
- REV: "nt",
1352
- TOB: "dc",
1353
- JDT: "dc",
1354
- ESG: "dc",
1355
- WIS: "dc",
1356
- SIR: "dc",
1357
- BAR: "dc",
1358
- LJE: "dc",
1359
- S3Y: "dc",
1360
- SUS: "dc",
1361
- BEL: "dc",
1362
- "1MA": "dc",
1363
- "2MA": "dc",
1364
- "3MA": "dc",
1365
- "4MA": "dc",
1366
- "1ES": "dc",
1367
- "2ES": "dc",
1368
- MAN: "dc",
1369
- PS2: "dc",
1370
- ODA: "dc",
1371
- PSS: "dc",
1372
- "3ES": "dc",
1373
- EZA: "dc",
1374
- "5EZ": "dc",
1375
- "6EZ": "dc",
1376
- DAG: "dc",
1377
- PS3: "dc",
1378
- "2BA": "dc",
1379
- LBA: "dc",
1380
- JUB: "dc",
1381
- ENO: "dc",
1382
- "1MQ": "dc",
1383
- "2MQ": "dc",
1384
- "3MQ": "dc",
1385
- REP: "dc",
1386
- "4BA": "dc",
1387
- LAO: "dc",
1388
- LKA: "nt"
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@youversion/platform-core",
3
- "version": "0.8.2",
3
+ "version": "0.9.0",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -1,5 +1,5 @@
1
1
  import { YouVersionPlatformConfiguration } from './YouVersionPlatformConfiguration';
2
- import type { SignInWithYouVersionPermissionValues } from './types/auth';
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, permissions, redirectURL, parameters);
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(permissions);
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(permissions: Set<SignInWithYouVersionPermissionValues>): string | null {
113
- const scopeArray = Array.from(permissions).sort();
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;