@go1/go1-embedding-react-sdk 0.1.0 → 0.3.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/README.md +3 -3
- package/dist/CHANGELOG.md +14 -0
- package/dist/README.md +3 -3
- package/dist/common/params.d.ts +1 -0
- package/dist/common/params.js +4 -0
- package/dist/common/types.d.ts +9 -4
- package/dist/common/types.js +1 -0
- package/dist/go1-embedding-react-sdk/src/index.js +14 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Go1 Embedding React SDK
|
|
2
2
|
|
|
3
|
-
A
|
|
3
|
+
A React hook to embed a Go1 content view in your site. Includes two-way messaging between your site and the Go1 content view.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -95,7 +95,7 @@ export type Experience = 'manager' | 'learner' | 'role-aware'
|
|
|
95
95
|
|
|
96
96
|
interface FeatureAttributeCommon {
|
|
97
97
|
shouldSuppressPreview?: boolean;
|
|
98
|
-
experience?: Experience;
|
|
98
|
+
experience?: Experience; // Defaults to `manager`
|
|
99
99
|
contentScope?: 'subscription' | 'library';
|
|
100
100
|
}
|
|
101
101
|
|
|
@@ -311,4 +311,4 @@ const onGo1MessageReceived = (message) => {
|
|
|
311
311
|
|
|
312
312
|
## Support
|
|
313
313
|
|
|
314
|
-
https://www.go1.com/developers
|
|
314
|
+
<https://www.go1.com/developers>
|
package/dist/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @go1/go1-embedding-react-sdk
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- New featureAttributes for Select Welcome Modal and Recommendation
|
|
8
|
+
- new Go1MessageType 'contact_go1_navigation'
|
|
9
|
+
- Add new feature auth-clients
|
|
10
|
+
|
|
11
|
+
## 0.2.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- new Go1MessageType 'contact_go1_navigation'
|
|
16
|
+
|
|
3
17
|
## 0.1.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
package/dist/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Go1 Embedding React SDK
|
|
2
2
|
|
|
3
|
-
A
|
|
3
|
+
A React hook to embed a Go1 content view in your site. Includes two-way messaging between your site and the Go1 content view.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -95,7 +95,7 @@ export type Experience = 'manager' | 'learner' | 'role-aware'
|
|
|
95
95
|
|
|
96
96
|
interface FeatureAttributeCommon {
|
|
97
97
|
shouldSuppressPreview?: boolean;
|
|
98
|
-
experience?: Experience;
|
|
98
|
+
experience?: Experience; // Defaults to `manager`
|
|
99
99
|
contentScope?: 'subscription' | 'library';
|
|
100
100
|
}
|
|
101
101
|
|
|
@@ -311,4 +311,4 @@ const onGo1MessageReceived = (message) => {
|
|
|
311
311
|
|
|
312
312
|
## Support
|
|
313
313
|
|
|
314
|
-
https://www.go1.com/developers
|
|
314
|
+
<https://www.go1.com/developers>
|
package/dist/common/params.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FeatureType } from './types';
|
|
2
2
|
export declare function addPortalURL(url: URL, portalURL: string, env?: 'staging' | 'production'): void;
|
|
3
3
|
export declare function addOneTimeToken(url: URL, oneTimeToken: string): void;
|
|
4
|
+
export declare function addForceReauth(url: URL): void;
|
|
4
5
|
export declare function isValidOTT(oneTimeToken: string): boolean;
|
|
5
6
|
export declare function isValidFeature(feature: FeatureType): boolean;
|
package/dist/common/params.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addPortalURL = addPortalURL;
|
|
4
4
|
exports.addOneTimeToken = addOneTimeToken;
|
|
5
|
+
exports.addForceReauth = addForceReauth;
|
|
5
6
|
exports.isValidOTT = isValidOTT;
|
|
6
7
|
exports.isValidFeature = isValidFeature;
|
|
7
8
|
const types_1 = require("./types");
|
|
@@ -25,6 +26,9 @@ function addOneTimeToken(url, oneTimeToken) {
|
|
|
25
26
|
throw new Error('Invalid formatting for oneTimeToken');
|
|
26
27
|
}
|
|
27
28
|
}
|
|
29
|
+
function addForceReauth(url) {
|
|
30
|
+
url.searchParams.append('force_reauth', 'true');
|
|
31
|
+
}
|
|
28
32
|
function isValidOTT(oneTimeToken) {
|
|
29
33
|
const validOTT = /^[A-Za-z0-9]+$/;
|
|
30
34
|
return validOTT.test(oneTimeToken);
|
package/dist/common/types.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export interface AdditionalInfoMessage {
|
|
|
7
7
|
feature: FeatureType;
|
|
8
8
|
additionalUserInfo?: AdditionalUserInfo;
|
|
9
9
|
featureAttributes?: FeatureAttributes;
|
|
10
|
-
themeInformation?: ThemeInformation;
|
|
10
|
+
themeInformation?: ThemeInformation | ThemeInformationElysium;
|
|
11
11
|
integrationSystemId?: string;
|
|
12
12
|
presentingIntegrationSystemId?: string;
|
|
13
13
|
experience?: FeatureAttributes['experience'];
|
|
@@ -16,7 +16,10 @@ export interface AdditionalInfoMessage {
|
|
|
16
16
|
export interface ThemeInformation {
|
|
17
17
|
accent: string;
|
|
18
18
|
}
|
|
19
|
-
export
|
|
19
|
+
export interface ThemeInformationElysium {
|
|
20
|
+
brandColor: string;
|
|
21
|
+
}
|
|
22
|
+
export type Go1MessageType = 'preview_start_content' | 'preview_close' | 'preview_add_content_success' | 'preview_add_content_failure' | 'preview_remove_content_success' | 'preview_remove_content_failure' | 'parent_show_preview' | 'set_additional_embedding_data' | 'go1_app_initialised' | 'ott_required' | 'search_result_selected' | 'search_filter_toggle' | 'search_redirected' | 'pass_ott' | 'set_access_token' | 'logout' | 'sync_content' | 'open_save_to_playlist_modal' | 'update_experience' | 'inter_feature_navigation' | 'side_drawer_open' | 'side_drawer_close' | 'elysium_modal_open' | 'elysium_modal_close' | 'play_content' | 'go1pay_custom_data' | 'bulk_upload_content' | 'bulk_upload_metadata' | 'bulk_upload_close' | 'contact_go1_navigation';
|
|
20
23
|
export type Go1Message = {
|
|
21
24
|
type: Go1MessageType;
|
|
22
25
|
payload?: any;
|
|
@@ -83,17 +86,18 @@ export interface FeatureAttributesGo1LearnSearch extends FeatureAttributeCommon
|
|
|
83
86
|
searchTerm?: string;
|
|
84
87
|
searchProvider?: string;
|
|
85
88
|
}
|
|
86
|
-
export type
|
|
89
|
+
export type SearchLearningObjectsOptions = {
|
|
87
90
|
providers?: string[];
|
|
88
91
|
skills?: string[];
|
|
89
92
|
topics?: string[];
|
|
90
93
|
sort?: string;
|
|
91
94
|
};
|
|
95
|
+
export type FeatureAttributesRecommendations = Omit<FeatureAttributesGo1LearnSearch, 'searchProvider'> & SearchLearningObjectsOptions;
|
|
92
96
|
export type FeatureAttributes = FeatureAttributesAIChat | FeatureAttributesPreview | FeatureAttributesWallet | FeatureAttributesLibrary | FeatureAttributesSearch | FeatureAttributesMyPlaylists | FeatureAttributesMyLearning | FeatureAttributesBulkUpload | FeatureAttributesContentStatus | FeatureAttributesGo1LearnSearch | FeatureAttributesRecommendations;
|
|
93
97
|
export interface AdditionalUserInfo {
|
|
94
98
|
jobTitle: string;
|
|
95
99
|
}
|
|
96
|
-
export declare const features: readonly ["ai-chat", "content-hub", "preview", "library", "search", "wallet", "content-retirement", "my-playlists", "activity-feed", "my-learning", "insights", "go1-learn/library", "go1-learn/my-learning", "go1-learn/learner-content", "go1-learn/search", "bulk-upload", "content-status", "partner-sales", "home", "recommendations"];
|
|
100
|
+
export declare const features: readonly ["ai-chat", "content-hub", "preview", "library", "search", "wallet", "content-retirement", "my-playlists", "activity-feed", "my-learning", "insights", "go1-learn/library", "go1-learn/my-learning", "go1-learn/learner-content", "go1-learn/search", "bulk-upload", "content-status", "partner-sales", "home", "recommendations", "auth-clients"];
|
|
97
101
|
export type FeatureType = (typeof features)[number];
|
|
98
102
|
export interface InitOptions {
|
|
99
103
|
feature: FeatureType;
|
|
@@ -105,6 +109,7 @@ export interface InitOptions {
|
|
|
105
109
|
additionalUserInfo?: AdditionalUserInfo;
|
|
106
110
|
themeInformation?: ThemeInformation;
|
|
107
111
|
oneTimeToken?: string;
|
|
112
|
+
accessToken?: string;
|
|
108
113
|
integrationSystemId?: string;
|
|
109
114
|
presentingIntegrationSystemId?: string;
|
|
110
115
|
previewHost?: string;
|
package/dist/common/types.js
CHANGED
|
@@ -6,7 +6,7 @@ const react_1 = require("react");
|
|
|
6
6
|
const constants_1 = require("../../common/constants");
|
|
7
7
|
const params_1 = require("../../common/params");
|
|
8
8
|
function useGo1ContentView(props) {
|
|
9
|
-
const { feature, featureAttributes, portalURL, oneTimeToken, onGo1MessageReceived, additionalUserInfo, themeInformation, integrationSystemId, presentingIntegrationSystemId, env = 'production', previewHost, disableFSOuterScript, } = props;
|
|
9
|
+
const { feature, featureAttributes, portalURL, oneTimeToken, onGo1MessageReceived, additionalUserInfo, themeInformation, integrationSystemId, presentingIntegrationSystemId, env = 'production', previewHost, disableFSOuterScript, accessToken, } = props;
|
|
10
10
|
const iframeRef = (0, react_1.useRef)(null);
|
|
11
11
|
let url = 'https://embedding.go1.com';
|
|
12
12
|
if (previewHost) {
|
|
@@ -29,9 +29,12 @@ function useGo1ContentView(props) {
|
|
|
29
29
|
if (oneTimeToken || oneTimeToken === '') {
|
|
30
30
|
(0, params_1.addOneTimeToken)(iframeURL, oneTimeToken);
|
|
31
31
|
}
|
|
32
|
+
if (accessToken) {
|
|
33
|
+
(0, params_1.addForceReauth)(iframeURL);
|
|
34
|
+
}
|
|
32
35
|
const iframeID = `go1-iframe-${feature}`;
|
|
33
36
|
return { iframeURL, iframeID };
|
|
34
|
-
}, [url, feature, portalURL, oneTimeToken, env]);
|
|
37
|
+
}, [url, feature, portalURL, oneTimeToken, env, accessToken]);
|
|
35
38
|
const eventListenerInstance = (0, react_1.useCallback)((event) => {
|
|
36
39
|
const { _type, ...rest } = event.data;
|
|
37
40
|
if (_type === constants_1.GO1_MESSAGE) {
|
|
@@ -50,6 +53,14 @@ function useGo1ContentView(props) {
|
|
|
50
53
|
payload,
|
|
51
54
|
});
|
|
52
55
|
}
|
|
56
|
+
else if (rest.type === 'ott_required' && rest.payload?.init === true && accessToken) {
|
|
57
|
+
sendMessageToGo1({
|
|
58
|
+
type: 'set_access_token',
|
|
59
|
+
payload: {
|
|
60
|
+
accessToken,
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
}
|
|
53
64
|
else {
|
|
54
65
|
if (onGo1MessageReceived) {
|
|
55
66
|
onGo1MessageReceived(rest);
|
|
@@ -66,6 +77,7 @@ function useGo1ContentView(props) {
|
|
|
66
77
|
onGo1MessageReceived,
|
|
67
78
|
feature,
|
|
68
79
|
disableFSOuterScript,
|
|
80
|
+
accessToken,
|
|
69
81
|
]);
|
|
70
82
|
(0, react_1.useEffect)(() => {
|
|
71
83
|
window.addEventListener('message', eventListenerInstance);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@go1/go1-embedding-react-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "A React library to embed Go1 content into your website.",
|
|
5
5
|
"main": "dist/go1-embedding-react-sdk/src/index.js",
|
|
6
6
|
"files": [
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@testing-library/jest-dom": "5.17.0",
|
|
24
24
|
"@testing-library/react": "14.0.0",
|
|
25
|
-
"@testing-library/user-event": "14.
|
|
25
|
+
"@testing-library/user-event": "14.5.2",
|
|
26
26
|
"jest": "^29.6.2",
|
|
27
27
|
"react": "18.2.0",
|
|
28
28
|
"react-dom": "^18.2.0",
|
|
29
29
|
"ts-jest": "^29.1.1",
|
|
30
|
-
"typescript": "^5.
|
|
30
|
+
"typescript": "^5.8.3"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"react": ">=16.8"
|