@youversion/platform-react-hooks 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.
@@ -1,4 +1,4 @@
1
1
 
2
- > @youversion/platform-react-hooks@0.8.2 build /home/runner/work/platform-sdk-react/platform-sdk-react/packages/hooks
2
+ > @youversion/platform-react-hooks@0.9.0 build /home/runner/work/platform-sdk-react/platform-sdk-react/packages/hooks
3
3
  > tsc -p tsconfig.build.json
4
4
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @youversion/platform-react-hooks
2
2
 
3
+ ## 0.9.0
4
+
5
+ ### Minor Changes
6
+
7
+ - e4f93b6: Update authentication system with enhanced OAuth scopes and API schema alignment
8
+
9
+ Key Changes:
10
+ - Added profile and email scopes to OAuth authentication
11
+ - Updated book resource schema to match new API endpoints
12
+ - Removed deprecated URLBuilder functionality
13
+
14
+ Breaking Changes:
15
+ - Book Schema: Must use the new updated book schema in any APIs returning bible book data Please enter a summary for your changes.
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies [e4f93b6]
20
+ - @youversion/platform-core@0.9.0
21
+
3
22
  ## 0.8.2
4
23
 
5
24
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/__tests__/mocks/auth.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE3F;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAI,YAAW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,KAAG,kBAmBxE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAC/B,YAAW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,KACtC,0BAaF,CAAC"}
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/__tests__/mocks/auth.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE3F;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAI,YAAW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,KAAG,kBAmBxE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAC/B,YAAW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,KACtC,0BAYF,CAAC"}
@@ -35,7 +35,6 @@ export const createMockAuthResult = (overrides = {}) => {
35
35
  idToken: 'id-token',
36
36
  refreshToken: 'refresh-token',
37
37
  expiresIn: 3600,
38
- permissions: ['bibles', 'highlights'],
39
38
  yvpUserId: 'test-yvp-user-id',
40
39
  profilePicture: 'https://example.com/profile.jpg',
41
40
  ...overrides,
@@ -1 +1 @@
1
- {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/__tests__/mocks/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE3F;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,YAAiC,EAAE,EAAsB,EAAE;IAC5F,MAAM,YAAY,GAAG,IAAI,kBAAkB,CAAC;QAC1C,EAAE,EAAE,KAAK;QACT,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,kBAAkB;QACzB,UAAU,EAAE,qDAAqD;QACjE,GAAG,SAAS;KACb,CAAC,CAAC;IAEH,2CAA2C;IAC3C,EAAE,CAAC,KAAK,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC,kBAAkB,CAAC,CAAC,KAAK,GAAG,GAAG,EAAE,MAAM,GAAG,GAAG,EAAE,EAAE;QACtF,IAAI,CAAC;YACH,OAAO,IAAI,GAAG,CAAC,oCAAoC,KAAK,MAAM,MAAM,EAAE,CAAC,CAAC;QAC1E,CAAC;QAAC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AAE,CAAC,CAAC;QAC1E,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,YAAqC,EAAE,EACX,EAAE;IAC9B,MAAM,YAAY,GAAG,kBAAkB,EAAE,CAAC;IAC1C,OAAO,IAAI,0BAA0B,CAAC;QACpC,GAAG,YAAY;QACf,WAAW,EAAE,cAAc;QAC3B,OAAO,EAAE,UAAU;QACnB,YAAY,EAAE,eAAe;QAC7B,SAAS,EAAE,IAAI;QACf,SAAS,EAAE,kBAAkB;QAC7B,cAAc,EAAE,iCAAiC;QACjD,GAAG,SAAS;KACb,CAAC,CAAC;AACL,CAAC,CAAC"}
@@ -1,9 +1,9 @@
1
- import { type AuthenticationState, type SignInWithYouVersionPermissionValues, type SignInWithYouVersionResult, type YouVersionUserInfo } from '@youversion/platform-core';
1
+ import { type AuthenticationState, type SignInWithYouVersionResult, type YouVersionUserInfo, type AuthenticationScopes } from '@youversion/platform-core';
2
2
  export interface UseYVAuthReturn {
3
3
  auth: AuthenticationState;
4
4
  signIn: (params: {
5
5
  redirectUrl: string;
6
- permissions?: SignInWithYouVersionPermissionValues[];
6
+ scopes?: AuthenticationScopes[];
7
7
  }) => Promise<void>;
8
8
  signOut: () => void;
9
9
  processCallback: () => Promise<SignInWithYouVersionResult | null>;
@@ -29,7 +29,6 @@ export interface UseYVAuthReturn {
29
29
  * try {
30
30
  * await signIn({
31
31
  * redirectUrl: 'https://myapp.com/callback',
32
- * permissions: [SignInWithYouVersionPermission.bibles]
33
32
  * });
34
33
  * } catch (error) {
35
34
  * console.error('Sign in failed:', error);
@@ -1 +1 @@
1
- {"version":3,"file":"useYVAuth.d.ts","sourceRoot":"","sources":["../src/useYVAuth.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,mBAAmB,EACx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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkFG;AACH,wBAAgB,SAAS,IAAI,eAAe,CA+D3C"}
package/dist/useYVAuth.js CHANGED
@@ -21,7 +21,6 @@ import { useYouVersionAuthContext } from './context/YouVersionAuthContext';
21
21
  * try {
22
22
  * await signIn({
23
23
  * redirectUrl: 'https://myapp.com/callback',
24
- * permissions: [SignInWithYouVersionPermission.bibles]
25
24
  * });
26
25
  * } catch (error) {
27
26
  * console.error('Sign in failed:', error);
@@ -101,8 +100,13 @@ export function useYVAuth() {
101
100
  return { accessToken: null, idToken: null };
102
101
  }, []);
103
102
  // Sign in function
104
- const signIn = useCallback(async ({ redirectUrl, permissions = [], }) => {
105
- await YouVersionAPIUsers.signIn(new Set(permissions), redirectUrl);
103
+ const signIn = useCallback(async ({ redirectUrl, scopes }) => {
104
+ if (scopes) {
105
+ await YouVersionAPIUsers.signIn(redirectUrl, scopes);
106
+ }
107
+ else {
108
+ await YouVersionAPIUsers.signIn(redirectUrl);
109
+ }
106
110
  // Note: This will redirect, so code after this won't execute
107
111
  }, []);
108
112
  // Process callback function
@@ -1 +1 @@
1
- {"version":3,"file":"useYVAuth.js","sourceRoot":"","sources":["../src/useYVAuth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EACL,kBAAkB,EAClB,+BAA+B,GAKhC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAoB3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmFG;AACH,MAAM,UAAU,SAAS;IACvB,uCAAuC;IACvC,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,wBAAwB,EAAE,CAAC;IAE/E,8BAA8B;IAC9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;YACX,MAAM,kBAAkB,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QACvD,CAAC;aAAM,CAAC;YACN,MAAM,kBAAkB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAC/C,CAAC;QACD,6DAA6D;IAC/D,CAAC,EACD,EAAE,CACH,CAAC;IAEF,4BAA4B;IAC5B,MAAM,eAAe,GAAG,WAAW,CAAC,KAAK,IAAgD,EAAE;QACzF,MAAM,MAAM,GAAG,MAAM,kBAAkB,CAAC,kBAAkB,EAAE,CAAC;QAC7D,OAAO,MAAM,CAAC;IAChB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,oBAAoB;IACpB,MAAM,IAAI,GAAwB,OAAO,CACvC,GAAG,EAAE,CAAC,CAAC;QACL,eAAe;QACf,SAAS;QACT,WAAW,EAAE,UAAU,CAAC,WAAW;QACnC,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,MAAM,EAAE,IAAI;QACZ,KAAK;KACN,CAAC,EACF,CAAC,eAAe,EAAE,SAAS,EAAE,UAAU,CAAC,WAAW,EAAE,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC,CAChF,CAAC;IAEF,oBAAoB;IACpB,MAAM,OAAO,GAAG,WAAW,CAAC,GAAG,EAAE;QAC/B,+BAA+B,CAAC,eAAe,EAAE,CAAC;QAClD,WAAW,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACL,IAAI;QACJ,MAAM;QACN,OAAO;QACP,eAAe;QACf,QAAQ;KACT,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@youversion/platform-react-hooks",
3
- "version": "0.8.2",
3
+ "version": "0.9.0",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -22,7 +22,7 @@
22
22
  }
23
23
  },
24
24
  "dependencies": {
25
- "@youversion/platform-core": "0.8.2"
25
+ "@youversion/platform-core": "0.9.0"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "react": ">=19.1.0 <20.0.0"
@@ -40,7 +40,6 @@ export const createMockAuthResult = (
40
40
  idToken: 'id-token',
41
41
  refreshToken: 'refresh-token',
42
42
  expiresIn: 3600,
43
- permissions: ['bibles', 'highlights'],
44
43
  yvpUserId: 'test-yvp-user-id',
45
44
  profilePicture: 'https://example.com/profile.jpg',
46
45
  ...overrides,
@@ -91,7 +91,6 @@ vi.mock('@youversion/platform-core', () => {
91
91
  expiryDate: Date | undefined;
92
92
  refreshToken: string | undefined;
93
93
  idToken: string | undefined;
94
- permissions: string[] | undefined;
95
94
  yvpUserId: string | undefined;
96
95
  name: string | undefined;
97
96
  profilePicture: string | undefined;
@@ -102,7 +101,6 @@ vi.mock('@youversion/platform-core', () => {
102
101
  expiresIn?: number;
103
102
  refreshToken?: string;
104
103
  idToken?: string;
105
- permissions?: string[];
106
104
  yvpUserId?: string;
107
105
  name?: string;
108
106
  profilePicture?: string;
@@ -114,7 +112,6 @@ vi.mock('@youversion/platform-core', () => {
114
112
  : new Date();
115
113
  this.refreshToken = props.refreshToken;
116
114
  this.idToken = props.idToken;
117
- this.permissions = props.permissions;
118
115
  this.yvpUserId = props.yvpUserId;
119
116
  this.name = props.name;
120
117
  this.profilePicture = props.profilePicture;
@@ -1,15 +1,12 @@
1
1
  /* eslint-disable @typescript-eslint/unbound-method, @typescript-eslint/no-unsafe-argument */
2
2
  import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
3
3
  import { renderHook, act } from '@testing-library/react';
4
- import {
5
- YouVersionAPIUsers,
6
- YouVersionPlatformConfiguration,
7
- SignInWithYouVersionPermission,
8
- } from '@youversion/platform-core';
4
+ import { YouVersionAPIUsers, YouVersionPlatformConfiguration } from '@youversion/platform-core';
9
5
  import { useYVAuth } from './useYVAuth';
10
6
  import { YouVersionAuthContext } from './context/YouVersionAuthContext';
11
7
  import { createMockUserInfo, createMockAuthResult } from './__tests__/mocks/auth';
12
8
  import { createAuthProviderWrapper } from './__tests__/utils/test-utils';
9
+ import type { AuthenticationScopes } from '@youversion/platform-core';
13
10
 
14
11
  // Mock the core modules
15
12
  vi.mock('@youversion/platform-core', () => {
@@ -94,7 +91,6 @@ vi.mock('@youversion/platform-core', () => {
94
91
  expiryDate: Date | undefined;
95
92
  refreshToken: string | undefined;
96
93
  idToken: string | undefined;
97
- permissions: string[] | undefined;
98
94
  yvpUserId: string | undefined;
99
95
  name: string | undefined;
100
96
  profilePicture: string | undefined;
@@ -105,7 +101,6 @@ vi.mock('@youversion/platform-core', () => {
105
101
  expiresIn?: number;
106
102
  refreshToken?: string;
107
103
  idToken?: string;
108
- permissions?: string[];
109
104
  yvpUserId?: string;
110
105
  name?: string;
111
106
  profilePicture?: string;
@@ -117,7 +112,6 @@ vi.mock('@youversion/platform-core', () => {
117
112
  : new Date();
118
113
  this.refreshToken = props.refreshToken;
119
114
  this.idToken = props.idToken;
120
- this.permissions = props.permissions;
121
115
  this.yvpUserId = props.yvpUserId;
122
116
  this.name = props.name;
123
117
  this.profilePicture = props.profilePicture;
@@ -199,19 +193,15 @@ describe('useYVAuth', () => {
199
193
  it('should call YouVersionAPIUsers.signIn with correct parameters', async () => {
200
194
  const { result } = await renderAuthHook();
201
195
  const redirectUrl = 'https://example.com/callback';
202
- const permissions = [SignInWithYouVersionPermission.bibles];
203
196
 
204
197
  await act(async () => {
205
- await result.current.signIn({ redirectUrl, permissions });
198
+ await result.current.signIn({ redirectUrl, scopes: ['profile'] });
206
199
  });
207
200
 
208
- expect(vi.mocked(YouVersionAPIUsers.signIn)).toHaveBeenCalledWith(
209
- new Set(permissions),
210
- redirectUrl,
211
- );
201
+ expect(vi.mocked(YouVersionAPIUsers.signIn)).toHaveBeenCalledWith(redirectUrl, ['profile']);
212
202
  });
213
203
 
214
- it('should call signIn with empty permissions when not provided', async () => {
204
+ it('should call signIn with empty scopes when not provided', async () => {
215
205
  const { result } = await renderAuthHook();
216
206
  const redirectUrl = 'https://example.com/callback';
217
207
 
@@ -219,7 +209,32 @@ describe('useYVAuth', () => {
219
209
  await result.current.signIn({ redirectUrl });
220
210
  });
221
211
 
222
- expect(vi.mocked(YouVersionAPIUsers.signIn)).toHaveBeenCalledWith(new Set([]), redirectUrl);
212
+ expect(vi.mocked(YouVersionAPIUsers.signIn)).toHaveBeenCalledWith(redirectUrl);
213
+ });
214
+
215
+ it('should call YouVersionAPIUsers.signIn exactly once with scopes', async () => {
216
+ const { result } = await renderAuthHook();
217
+ const redirectUrl = 'https://example.com/callback';
218
+ const scopes: AuthenticationScopes[] = ['profile', 'email'];
219
+
220
+ await act(async () => {
221
+ await result.current.signIn({ redirectUrl, scopes });
222
+ });
223
+
224
+ expect(vi.mocked(YouVersionAPIUsers.signIn)).toHaveBeenCalledTimes(1);
225
+ expect(vi.mocked(YouVersionAPIUsers.signIn)).toHaveBeenCalledWith(redirectUrl, scopes);
226
+ });
227
+
228
+ it('should call YouVersionAPIUsers.signIn exactly once without scopes', async () => {
229
+ const { result } = await renderAuthHook();
230
+ const redirectUrl = 'https://example.com/callback';
231
+
232
+ await act(async () => {
233
+ await result.current.signIn({ redirectUrl });
234
+ });
235
+
236
+ expect(vi.mocked(YouVersionAPIUsers.signIn)).toHaveBeenCalledTimes(1);
237
+ expect(vi.mocked(YouVersionAPIUsers.signIn)).toHaveBeenCalledWith(redirectUrl);
223
238
  });
224
239
 
225
240
  it('should throw error when signIn fails', async () => {
package/src/useYVAuth.ts CHANGED
@@ -3,9 +3,9 @@ import {
3
3
  YouVersionAPIUsers,
4
4
  YouVersionPlatformConfiguration,
5
5
  type AuthenticationState,
6
- type SignInWithYouVersionPermissionValues,
7
6
  type SignInWithYouVersionResult,
8
7
  type YouVersionUserInfo,
8
+ type AuthenticationScopes,
9
9
  } from '@youversion/platform-core';
10
10
  import { useYouVersionAuthContext } from './context/YouVersionAuthContext';
11
11
 
@@ -14,10 +14,7 @@ export interface UseYVAuthReturn {
14
14
  auth: AuthenticationState;
15
15
 
16
16
  // Actions
17
- signIn: (params: {
18
- redirectUrl: string;
19
- permissions?: SignInWithYouVersionPermissionValues[];
20
- }) => Promise<void>;
17
+ signIn: (params: { redirectUrl: string; scopes?: AuthenticationScopes[] }) => Promise<void>;
21
18
  signOut: () => void;
22
19
 
23
20
  // Callback processing (for callback page) - caches user info
@@ -47,7 +44,6 @@ export interface UseYVAuthReturn {
47
44
  * try {
48
45
  * await signIn({
49
46
  * redirectUrl: 'https://myapp.com/callback',
50
- * permissions: [SignInWithYouVersionPermission.bibles]
51
47
  * });
52
48
  * } catch (error) {
53
49
  * console.error('Sign in failed:', error);
@@ -131,14 +127,12 @@ export function useYVAuth(): UseYVAuthReturn {
131
127
 
132
128
  // Sign in function
133
129
  const signIn = useCallback(
134
- async ({
135
- redirectUrl,
136
- permissions = [],
137
- }: {
138
- redirectUrl: string;
139
- permissions?: SignInWithYouVersionPermissionValues[];
140
- }) => {
141
- await YouVersionAPIUsers.signIn(new Set(permissions), redirectUrl);
130
+ async ({ redirectUrl, scopes }: { redirectUrl: string; scopes?: AuthenticationScopes[] }) => {
131
+ if (scopes) {
132
+ await YouVersionAPIUsers.signIn(redirectUrl, scopes);
133
+ } else {
134
+ await YouVersionAPIUsers.signIn(redirectUrl);
135
+ }
142
136
  // Note: This will redirect, so code after this won't execute
143
137
  },
144
138
  [],