@go1/go1-embedding-react-sdk 0.1.0 → 0.2.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/CHANGELOG.md
CHANGED
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
|
@@ -16,7 +16,7 @@ export interface AdditionalInfoMessage {
|
|
|
16
16
|
export interface ThemeInformation {
|
|
17
17
|
accent: string;
|
|
18
18
|
}
|
|
19
|
-
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' | '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';
|
|
19
|
+
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
20
|
export type Go1Message = {
|
|
21
21
|
type: Go1MessageType;
|
|
22
22
|
payload?: any;
|
|
@@ -83,12 +83,13 @@ export interface FeatureAttributesGo1LearnSearch extends FeatureAttributeCommon
|
|
|
83
83
|
searchTerm?: string;
|
|
84
84
|
searchProvider?: string;
|
|
85
85
|
}
|
|
86
|
-
export type
|
|
86
|
+
export type SearchLearningObjectsOptions = {
|
|
87
87
|
providers?: string[];
|
|
88
88
|
skills?: string[];
|
|
89
89
|
topics?: string[];
|
|
90
90
|
sort?: string;
|
|
91
91
|
};
|
|
92
|
+
export type FeatureAttributesRecommendations = Omit<FeatureAttributesGo1LearnSearch, 'searchProvider'> & SearchLearningObjectsOptions;
|
|
92
93
|
export type FeatureAttributes = FeatureAttributesAIChat | FeatureAttributesPreview | FeatureAttributesWallet | FeatureAttributesLibrary | FeatureAttributesSearch | FeatureAttributesMyPlaylists | FeatureAttributesMyLearning | FeatureAttributesBulkUpload | FeatureAttributesContentStatus | FeatureAttributesGo1LearnSearch | FeatureAttributesRecommendations;
|
|
93
94
|
export interface AdditionalUserInfo {
|
|
94
95
|
jobTitle: string;
|
|
@@ -105,6 +106,7 @@ export interface InitOptions {
|
|
|
105
106
|
additionalUserInfo?: AdditionalUserInfo;
|
|
106
107
|
themeInformation?: ThemeInformation;
|
|
107
108
|
oneTimeToken?: string;
|
|
109
|
+
accessToken?: string;
|
|
108
110
|
integrationSystemId?: string;
|
|
109
111
|
presentingIntegrationSystemId?: string;
|
|
110
112
|
previewHost?: string;
|
|
@@ -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.2.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"
|