Skip to content

Commit

Permalink
Merge branch 'development' into WRPD-feature-377
Browse files Browse the repository at this point in the history
  • Loading branch information
arkaprota authored Oct 14, 2024
2 parents 07ea367 + a75bac6 commit 52c6522
Show file tree
Hide file tree
Showing 10 changed files with 354 additions and 7 deletions.
67 changes: 67 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,73 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [0.0.560](https://github.com/wrappid/core/compare/v0.0.559...v0.0.560) (2024-10-12)


### Features

* **core:** :sparkles: google sign-in implementaion ([53dc5a2](https://github.com/wrappid/core/commit/53dc5a2e102825c1c9666539b24c26b1a3ed08c8)), closes [#397](https://github.com/wrappid/core/issues/397)

### [0.0.559](https://github.com/wrappid/core/compare/v0.0.558...v0.0.559) (2024-10-11)


### Bug Fixes

* **core:** :bug: fix github login ([a777c19](https://github.com/wrappid/core/commit/a777c19856e20ff11a62f775d31ea0217a0ee315)), closes [#394](https://github.com/wrappid/core/issues/394)

### [0.0.558](https://github.com/wrappid/core/compare/v0.0.557...v0.0.558) (2024-10-10)

### [0.0.557](https://github.com/wrappid/core/compare/v0.0.556...v0.0.557) (2024-10-10)


### Features

* **core:** :sparkles: add the github auth ([8b4e883](https://github.com/wrappid/core/commit/8b4e883b265555d7250d75528a805a18d99d50bf)), closes [#381](https://github.com/wrappid/core/issues/381)
* **core:** :sparkles: adds the github auth component ([e2d65e6](https://github.com/wrappid/core/commit/e2d65e60a05f783712856e19e452f31375748256)), closes [#381](https://github.com/wrappid/core/issues/381)
* **core:** :sparkles: github auth component added ([a3e934e](https://github.com/wrappid/core/commit/a3e934ef1560b68a98b048832b5abe46813f23a4)), closes [#381](https://github.com/wrappid/core/issues/381)


### Bug Fixes

* **core:** :bug: fix GitHub and LinkedIn call automatically ([137fe4e](https://github.com/wrappid/core/commit/137fe4eaae80b027216b1c3e1e538b77d9b52f1d)), closes [#394](https://github.com/wrappid/core/issues/394)

### [0.0.556](https://github.com/wrappid/core/compare/v0.0.555...v0.0.556) (2024-10-10)


### Features

* **core:** :sparkles: added a linkedinAuthComponent ([b5ef953](https://github.com/wrappid/core/commit/b5ef953967c33f7ad7e0ba5860311d194aadd219)), closes [#382](https://github.com/wrappid/core/issues/382)
* **core:** :sparkles: added a login with linkedIn flow ([ba7c929](https://github.com/wrappid/core/commit/ba7c929652e4c00680aa1407216e12e868075809)), closes [#382](https://github.com/wrappid/core/issues/382)
* **core:** :sparkles: added linkedin auth component ([d92959b](https://github.com/wrappid/core/commit/d92959b8429ee7f5a62b080d74b0ad83c3829a79)), closes [#97](https://github.com/wrappid/core/issues/97)
* **core:** :sparkles: added linkedin auth component ([582fec1](https://github.com/wrappid/core/commit/582fec15063ca4370b7007093ad84fe7ab2260e3)), closes [#97](https://github.com/wrappid/core/issues/97)
* **core:** :sparkles: implemented a feature which will allow users to login with linkedIn ([9461e3b](https://github.com/wrappid/core/commit/9461e3bad00e58b42eb87ec4a060d522eabb5435)), closes [#382](https://github.com/wrappid/core/issues/382)
* **core:** :sparkles: implemented a login with linkedin feature ([ee2708e](https://github.com/wrappid/core/commit/ee2708e381788c613227e1aa951d1fb8563ec234)), closes [#382](https://github.com/wrappid/core/issues/382)


### Bug Fixes

* **global:** :bug: facbooklogin fix ([fe0a4a0](https://github.com/wrappid/core/commit/fe0a4a0f468cc91c19998920db4224d4703eb639)), closes [#383](https://github.com/wrappid/core/issues/383)

### [0.0.555](https://github.com/wrappid/core/compare/v0.0.554...v0.0.555) (2024-10-03)

### [0.0.554](https://github.com/wrappid/core/compare/v0.0.553...v0.0.554) (2024-10-03)

### [0.0.553](https://github.com/wrappid/core/compare/v0.0.552...v0.0.553) (2024-10-03)


### Bug Fixes

* **core:** :bug: facebook login fix ([2c85db2](https://github.com/wrappid/core/commit/2c85db2f9c0199825de9ec9e76a04c46c2ebb20a)), closes [#383](https://github.com/wrappid/core/issues/383)

### [0.0.552](https://github.com/wrappid/core/compare/v0.0.551...v0.0.552) (2024-10-03)

### [0.0.551](https://github.com/wrappid/core/compare/v0.0.550...v0.0.551) (2024-10-03)


### Features

* **core:** :sparkles: facebook auth component implementation ([5ac126f](https://github.com/wrappid/core/commit/5ac126f7158db442c339521bcf11450c07fdee3a)), closes [#383](https://github.com/wrappid/core/issues/383)

### [0.0.550](https://github.com/wrappid/core/compare/v0.0.549...v0.0.550) (2024-09-26)

### [0.0.549](https://github.com/wrappid/core/compare/v0.0.548...v0.0.549) (2024-09-25)
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wrappid/core",
"version": "0.0.550",
"version": "0.0.560",
"description": "Multi platform app builder core package.",
"main": "index.js",
"scripts": {
Expand Down
84 changes: 84 additions & 0 deletions package/components/inputs/custom/FacebookAuthComponent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// eslint-disable-next-line unused-imports/no-unused-imports, no-unused-vars
import React, { useEffect } from "react";

// eslint-disable-next-line import/no-unresolved
import { NativeFacebookAuthComponent } from "@wrappid/native";
// eslint-disable-next-line import/no-unresolved
import { WrappidDataContext } from "@wrappid/styles";
import { useDispatch } from "react-redux";

import { HTTP } from "../../../config/constants";
import { apiRequestAction } from "../../../store/action/appActions";
import CoreButton from "../CoreButton";

const FacebookAuthComponent = (props) => {
const dispatch = useDispatch();
const { config } = React.useContext(WrappidDataContext);

useEffect(() => {
// Load the Facebook SDK
window.fbAsyncInit = function () {
window.FB.init({
appId : config?.wrappid?.socialLogin?.facebook?.appId,
config_id: config?.wrappid?.socialLogin?.facebook?.configId,
cookie : true,
version : "v20.0",
xfbml : true,

});
};

(function (document, elementType, scriptId) {
let facebookScript,
fjs = document.getElementsByTagName(elementType)[0];

if (document.getElementById(scriptId)) return;
facebookScript = document.createElement(elementType);
facebookScript.id = scriptId;
facebookScript.src = "https://connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(facebookScript, fjs);
})(document, "script", "facebook-jssdk");
}, []);

const handleFacebookLogin = () => {
window.FB.login(
function (response) {
if (response.authResponse) {
fetchUserData(response.authResponse.accessToken);
}
},
{
config_id : config?.wrappid?.socialLogin?.facebook?.configId,
response_type: "code",
scope : "public_profile,email",
}
);
};

const fetchUserData = (accessToken) => {
const data = { platformToken: accessToken };

dispatch(
apiRequestAction(
HTTP.POST,
"/login/social/facebook",
false,
data,
"LOGIN_SUCCESS",
"LOGIN_ERROR"
)
);
};

return (
<NativeFacebookAuthComponent
onClick={() => handleFacebookLogin()}
label="Facebook"
{...props}
/>
);
};

FacebookAuthComponent.ValidProps = [...CoreButton.validProps];

export default FacebookAuthComponent;
47 changes: 47 additions & 0 deletions package/components/inputs/custom/GithubAuthComponent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/* eslint-disable etc/no-commented-out-code */
/* eslint-disable import/no-unresolved */
import React, { useEffect, useState } from "react";

import { apiRequestAction, HTTP } from "@wrappid/core";
import { NativeGithubAuthComponent } from "@wrappid/native";
import { WrappidDataContext } from "@wrappid/styles";
import { useDispatch } from "react-redux";

export default function GithubAuthComponent(props) {
const { config } = React.useContext(WrappidDataContext);
const dispatch = useDispatch();
const [github_code, setGithub_code] = useState("");

useEffect(() => {
const currentUrl = window.location.href;

const state = new URLSearchParams(window.location.search).get("state");

if (currentUrl.includes("checkUserExist?code=") && state === null) {
const urlParams = new URLSearchParams(window.location.search);
const extractedCode = urlParams.get("code");

setGithub_code(extractedCode);
}
}, []);

useEffect(() => {
const backend_Endpoint = "/login/social/github";

if(github_code === ""){return;}
dispatch(
apiRequestAction(HTTP.POST, backend_Endpoint, false, { "platformToken": github_code }, "LOGIN_SUCCESS",
"LOGIN_ERROR"));
setGithub_code("");
}, [github_code]);

const handleAuthoriseGithub = () => {

const clientId = config.wrappid.socialLogin.github.clientId;

window.location.href = `https://github.com/login/oauth/authorize?client_id=${clientId}&scope=repo,discussions,read:user,user:email `;
return;
};

return (<NativeGithubAuthComponent onClick={handleAuthoriseGithub} {...props} label="Github"/>);
}
71 changes: 71 additions & 0 deletions package/components/inputs/custom/GoogleAuthComponent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// eslint-disable-next-line no-unused-vars, unused-imports/no-unused-imports
import React, { useEffect, useRef } from "react";

// eslint-disable-next-line import/no-unresolved
import { WrappidDataContext } from "@wrappid/styles";
import { useDispatch } from "react-redux";

import { HTTP } from "../../../config/constants";
import { apiRequestAction } from "../../../store/action/appActions";
import CoreBox from "../../layouts/CoreBox";

const GoogleAuthComponent = () => {
const { config } = React.useContext(WrappidDataContext);
const dispatch = useDispatch();

const buttonRef = useRef(null);

useEffect(() => {
const script = document.createElement("script");

script.src = "https://accounts.google.com/gsi/client";
script.async = true;
script.defer = true;
script.onload = initializeGoogleSignIn;
document.body.appendChild(script);

return () => {
document.body.removeChild(script);
};
}, []);

const handleCredentialResponse = (response) => {
// You can send this token to your server or handle it as needed
const data = { platformToken: response.credential };

dispatch(
apiRequestAction(
HTTP.POST,
"/login/social/google",
false,
data,
"LOGIN_SUCCESS",
"LOGIN_ERROR"
)
);
};

const initializeGoogleSignIn = () => {
if (window.google) {
window.google.accounts.id.initialize({

auto_select: true,
// Replace with your actual client ID
callback : handleCredentialResponse,
client_id : config.wrappid.socialLogin.google.clientId
});

window.google.accounts.id.renderButton(
buttonRef.current,
{ size: "large", theme: "outline" } // customization attributes
);
window.google.accounts.id.prompt(); // also display the One Tap dialog
}
};

return (
<CoreBox ref={buttonRef}></CoreBox>
);
};

export default GoogleAuthComponent;
74 changes: 74 additions & 0 deletions package/components/inputs/custom/LinkedInAuthComponent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/* eslint-disable no-console */
// eslint-disable-next-line unused-imports/no-unused-imports, no-unused-vars
import React, { useState, useEffect } from "react";

// eslint-disable-next-line import/no-unresolved
import { NativeLinkedInAuthComponent } from "@wrappid/native";
// eslint-disable-next-line import/no-unresolved
import { WrappidDataContext } from "@wrappid/styles";
import { useDispatch } from "react-redux";

import CoreButton from "./../CoreButton";
import { HTTP } from "../../../config/constants";
import { apiRequestAction } from "../../../store/action/appActions";
import CoreBox from "../../layouts/CoreBox";

export default function LinkedInAuthComponent(props){
const { config } = React.useContext(WrappidDataContext);
const dispatch = useDispatch();

const clientId = config?.wrappid?.socialLogin?.linkedin?.apiKey;
const redirectUri = config?.wrappid?.socialLogin?.linkedin?.callbackURL;
const scopes = "profile w_member_social email openid";
const state = "4b1a92d8c1e7a9";

const authUrl = `https://www.linkedin.com/oauth/v2/authorization?response_type=code&client_id=${clientId}&redirect_uri=${encodeURIComponent(
redirectUri
)}&state=${state}&scope=${encodeURIComponent(scopes)}`;

const handleClick = () => {
// Redirect user to LinkedIn auth URL
console.log(authUrl);
window.location.href = authUrl;
};
const fetchUserData = (authCode) => {
const data = { platformToken: authCode };

dispatch(
apiRequestAction(
HTTP.POST,
"/login/social/linkedin",
false,
data,
"LOGIN_SUCCESS",
"LOGIN_ERROR"
)
);
};
const [authCode, setAuthCode] = useState(null);

useEffect(() => {
// Extract the authorization code from the URL
const queryParams = new URLSearchParams(window.location.search);
const state = new URLSearchParams(window.location.search).get("state");

const code = queryParams.get("code");

if ((code != null) && (state != null)) {
setAuthCode(code);
}

if(authCode !== null){
// eslint-disable-next-line no-unused-vars
fetchUserData(authCode);
}
}, [authCode]);

return (
<CoreBox>
<NativeLinkedInAuthComponent onClick={handleClick} {...props} label="LinkedIn"/>
</CoreBox>
);
}

LinkedInAuthComponent.validProps = [...CoreButton.validProps];
6 changes: 5 additions & 1 deletion package/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ import CoreTextButton from "./components/inputs/CoreTextButton";
import CoreTextField from "./components/inputs/CoreTextField";
import CoreTimePicker from "./components/inputs/CoreTimePicker";
import CoreTimeRangePicker from "./components/inputs/CoreTimeRangePicker";
import FacebookAuthComponent from "./components/inputs/custom/FacebookAuthComponent";
import GithubAuthComponent from "./components/inputs/custom/GithubAuthComponent";
import GoogleAuthComponent from "./components/inputs/custom/GoogleAuthComponent";
import LinkedInAuthComponent from "./components/inputs/custom/LinkedInAuthComponent";
import CoreForm from "./components/inputs/forms/CoreForm";
import {
FORM_EDIT_MODE,
Expand Down Expand Up @@ -337,6 +341,6 @@ export {
ThemeSelector, ThreeColumnLayout, toggleMenuItemState, toggleRightMenuState, TwoColumnLayout, urls, useDynamicRefs,
// Network status custom hook
useNetworkStatus, UserChip, VCenteredBlankLayout, viewFormattedDate, WEB_PLATFORM, XLargeCoreStyles,
XXLargeCoreStyles
XXLargeCoreStyles, FacebookAuthComponent, GithubAuthComponent, LinkedInAuthComponent, GoogleAuthComponent
};

Loading

0 comments on commit 52c6522

Please sign in to comment.