@youversion/platform-react-hooks 0.8.1 → 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 +1 -1
- package/CHANGELOG.md +30 -0
- package/dist/__tests__/mocks/auth.d.ts.map +1 -1
- package/dist/__tests__/mocks/auth.js +0 -1
- package/dist/__tests__/mocks/auth.js.map +1 -1
- package/dist/context/YouVersionProvider.js +1 -1
- package/dist/context/YouVersionProvider.js.map +1 -1
- package/dist/useYVAuth.d.ts +2 -3
- package/dist/useYVAuth.d.ts.map +1 -1
- package/dist/useYVAuth.js +7 -3
- package/dist/useYVAuth.js.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/mocks/auth.ts +0 -1
- package/src/context/YouVersionAuthProvider.test.tsx +0 -3
- package/src/context/YouVersionProvider.tsx +1 -1
- package/src/useFilteredVersions.test.tsx +10 -10
- package/src/useYVAuth.test.tsx +31 -16
- package/src/useYVAuth.ts +8 -14
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
> @youversion/platform-react-hooks@0.
|
|
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,35 @@
|
|
|
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
|
+
|
|
22
|
+
## 0.8.2
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- 93be9ef: Update types, zod schemas, and test mocks for the following updated endpoints:
|
|
27
|
+
- get bible books
|
|
28
|
+
- get bible chapters
|
|
29
|
+
- get bible verses
|
|
30
|
+
- Updated dependencies [93be9ef]
|
|
31
|
+
- @youversion/platform-core@0.8.2
|
|
32
|
+
|
|
3
33
|
## 0.8.1
|
|
4
34
|
|
|
5
35
|
### 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,
|
|
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,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,YA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3B,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"}
|
|
@@ -17,7 +17,7 @@ export function YouVersionProvider(props) {
|
|
|
17
17
|
if (includeAuth) {
|
|
18
18
|
const { authRedirectUrl } = props;
|
|
19
19
|
// Installation ID gets set automatically by YouVersionPlatformConfiguration
|
|
20
|
-
return (_jsx(YouVersionContext.Provider, { value: { appKey, apiHost, installationId: YouVersionPlatformConfiguration.installationId }, children: _jsx(Suspense, { children: _jsx(AuthProvider, { config: { appKey, apiHost, redirectUri: authRedirectUrl }, children: children }) }) }));
|
|
20
|
+
return (_jsx(YouVersionContext.Provider, { value: { appKey, apiHost, installationId: YouVersionPlatformConfiguration.installationId }, children: _jsx(Suspense, { children: _jsx(AuthProvider, { config: { appKey, apiHost, redirectUri: authRedirectUrl }, children: _jsx("div", { "data-yv-sdk": true, children: children }) }) }) }));
|
|
21
21
|
}
|
|
22
22
|
// Installation ID gets set automatically by YouVersionPlatformConfiguration
|
|
23
23
|
return (_jsx(YouVersionContext.Provider, { value: { appKey, apiHost, installationId: YouVersionPlatformConfiguration.installationId }, children: children }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"YouVersionProvider.js","sourceRoot":"","sources":["../../src/context/YouVersionProvider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAkB5E,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,0BAA0B,CAAC,CAAC,CAAC;AAEpE,MAA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;IAEhF,gEAAgE;IAChE,4DAA4D;IAC5D,6DAA6D;IAC7D,wCAAwC;IACxC,SAAS,CAAC,GAAG,EAAE;QACb,+BAA+B,CAAC,MAAM,GAAG,MAAM,CAAC;QAChD,+BAA+B,CAAC,OAAO,GAAG,OAAO,CAAC;IACpD,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAEtB,IAAI,WAAW,EAAE,CAAC;QAChB,MAAM,EAAE,eAAe,EAAE,GAAG,KAAK,CAAC;QAElC,4EAA4E;QAC5E,OAAO,CACL,KAAC,iBAAiB,CAAC,QAAQ,IACzB,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,+BAA+B,CAAC,cAAc,EAAE,YAE1F,KAAC,QAAQ,cACP,KAAC,YAAY,IAAC,MAAM,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,YACrE,6CAAkB,QAAQ,GAAO,GACpB,GACN,GACgB,CAC9B,CAAC;IACJ,CAAC;IAED,4EAA4E;IAC5E,OAAO,CACL,KAAC,iBAAiB,CAAC,QAAQ,IACzB,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,+BAA+B,CAAC,cAAc,EAAE,YAEzF,QAAQ,GACkB,CAC9B,CAAC;AACJ,CAAC"}
|
package/dist/useYVAuth.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { type AuthenticationState, type
|
|
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
|
-
|
|
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);
|
package/dist/useYVAuth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useYVAuth.d.ts","sourceRoot":"","sources":["../src/useYVAuth.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,mBAAmB,EACxB,KAAK,
|
|
1
|
+
{"version":3,"file":"useYVAuth.d.ts","sourceRoot":"","sources":["../src/useYVAuth.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,mBAAmB,EACxB,KAAK,0BAA0B,EAC/B,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EAC1B,MAAM,2BAA2B,CAAC;AAGnC,MAAM,WAAW,eAAe;IAE9B,IAAI,EAAE,mBAAmB,CAAC;IAG1B,MAAM,EAAE,CAAC,MAAM,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,oBAAoB,EAAE,CAAA;KAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5F,OAAO,EAAE,MAAM,IAAI,CAAC;IAGpB,eAAe,EAAE,MAAM,OAAO,CAAC,0BAA0B,GAAG,IAAI,CAAC,CAAC;IAGlE,QAAQ,EAAE,kBAAkB,GAAG,IAAI,CAAC;CACrC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,
|
|
105
|
-
|
|
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
|
package/dist/useYVAuth.js.map
CHANGED
|
@@ -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;
|
|
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;AAiB3E;;;;;;;;;;;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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.
|
|
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.
|
|
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;
|
|
@@ -13,8 +13,8 @@ const mockVersions: BibleVersion[] = [
|
|
|
13
13
|
info: null,
|
|
14
14
|
publisher_url: null,
|
|
15
15
|
language_tag: 'en',
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
localized_abbreviation: 'KJV',
|
|
17
|
+
localized_title: 'King James Version',
|
|
18
18
|
books: [],
|
|
19
19
|
youversion_deep_link: 'https://www.bible.com/versions/1',
|
|
20
20
|
},
|
|
@@ -27,8 +27,8 @@ const mockVersions: BibleVersion[] = [
|
|
|
27
27
|
info: null,
|
|
28
28
|
publisher_url: null,
|
|
29
29
|
language_tag: 'en',
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
localized_abbreviation: 'NIV',
|
|
31
|
+
localized_title: 'New International Version',
|
|
32
32
|
books: [],
|
|
33
33
|
youversion_deep_link: 'https://www.bible.com/versions/2',
|
|
34
34
|
},
|
|
@@ -41,8 +41,8 @@ const mockVersions: BibleVersion[] = [
|
|
|
41
41
|
info: null,
|
|
42
42
|
publisher_url: null,
|
|
43
43
|
language_tag: 'es',
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
localized_abbreviation: 'RVR1960',
|
|
45
|
+
localized_title: 'Reina-Valera 1960',
|
|
46
46
|
books: [],
|
|
47
47
|
youversion_deep_link: 'https://www.bible.com/versions/3',
|
|
48
48
|
},
|
|
@@ -55,8 +55,8 @@ const mockVersions: BibleVersion[] = [
|
|
|
55
55
|
info: null,
|
|
56
56
|
publisher_url: null,
|
|
57
57
|
language_tag: 'es',
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
localized_abbreviation: 'NVI',
|
|
59
|
+
localized_title: 'Nueva Versión Internacional',
|
|
60
60
|
books: [],
|
|
61
61
|
youversion_deep_link: 'https://www.bible.com/versions/4',
|
|
62
62
|
},
|
|
@@ -69,8 +69,8 @@ const mockVersions: BibleVersion[] = [
|
|
|
69
69
|
info: null,
|
|
70
70
|
publisher_url: null,
|
|
71
71
|
language_tag: 'fr',
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
localized_abbreviation: 'BDS',
|
|
73
|
+
localized_title: 'La Bible du Semeur',
|
|
74
74
|
books: [],
|
|
75
75
|
youversion_deep_link: 'https://www.bible.com/versions/5',
|
|
76
76
|
},
|
package/src/useYVAuth.test.tsx
CHANGED
|
@@ -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,
|
|
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
|
|
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(
|
|
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
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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
|
[],
|