Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
5feb6b1
chore: init new major v8
hschoenenberger May 6, 2025
7027a09
[ACCOUNT-2595/2604] feat: create & verify shop identity (#433)
atourneriePresta Jun 5, 2025
a38c18d
fix: shop verification error (#496)
antoinemetifeu Jun 10, 2025
803e259
feat: verif implicit (#499)
antoinemetifeu Jun 10, 2025
03f91ae
[ACCOUNT-2832] feat: identify contact (#481)
hschoenenberger Jun 10, 2025
b78e25f
Add store audience (#501)
antoinemetifeu Jun 12, 2025
cb39e74
Merge remote-tracking branch 'origin/main' into major/v8
hschoenenberger Jun 12, 2025
23ba011
fix: don't disconnect bo when identify contact flow fails (#502)
hschoenenberger Jun 12, 2025
060c341
Merge branch 'main' into major/v8
hschoenenberger Jun 23, 2025
e41dca8
[ACCOUNT-2945] feat: fallback session for ps16 (#506)
hschoenenberger Jun 24, 2025
5e7e291
[ACCOUNT-2953] Compat firebase tokens (#505)
antoinemetifeu Jun 27, 2025
0b4fd03
[ACCOUNT-2853] feat: upgrade to v8 (#503)
guillaume60240 Jun 27, 2025
1d1a9c9
fix: debug hook display condition
hschoenenberger Jun 27, 2025
6e558e6
fix: cache invalidation
hschoenenberger Jun 27, 2025
65129c0
feat: add shop status accessors into PsAccountsService and update rea…
hschoenenberger Jul 1, 2025
37718ac
feat: refresh invalid token (#510)
hschoenenberger Jul 2, 2025
34fbd38
fix: status manager circular dep (#517)
hschoenenberger Jul 15, 2025
4e2f56c
fix: generic beta tag for component version
hschoenenberger Jul 16, 2025
4b2ea02
feat: debugbar alert env (#518)
hschoenenberger Jul 17, 2025
898016a
feat: get last upgraded version (#513)
hschoenenberger Jul 29, 2025
7ea8940
refactor: introduce header constants (#522)
hschoenenberger Jul 31, 2025
fe16271
refactor: improve upgrade service (#524)
antoinemetifeu Aug 6, 2025
e7179cd
fix: plugin upgrade service (#529)
hschoenenberger Aug 6, 2025
9273463
[ACCOUNT-2608] Manual verify shop (#519)
sullivan-monteiro Aug 6, 2025
f195a68
[ACCOUNT-3038] feat: context with empty status (#531)
hschoenenberger Aug 11, 2025
c881efc
[ACCOUNT-3019] Manual verification tracking (#520)
antoinemetifeu Aug 12, 2025
4595525
fix: declare new admin controllers at upgrade time
hschoenenberger Aug 12, 2025
a948434
feat: finish the job providing source tracking (#537)
hschoenenberger Aug 19, 2025
a157798
feat: remove admin debug controller (#534)
hschoenenberger Aug 19, 2025
5362a4f
feat: two steps creation & verification (#538)
hschoenenberger Aug 20, 2025
dfbdbe7
[ACCOUNT-3009] fix: IFrame integration - CORS admin controller (#528)
hschoenenberger Aug 21, 2025
09ddf7d
feat: remove fallback vue component (#535)
hschoenenberger Aug 22, 2025
4a2167c
fix: use fallback session to avoid interacting with ps session (#539)
hschoenenberger Aug 22, 2025
258a0a5
Merge remote-tracking branch 'origin/main' into major/v8
hschoenenberger Aug 22, 2025
62c6f5c
feat: improve upgrade script (#542)
hschoenenberger Aug 28, 2025
77da8bb
[ACCOUNT-3069] fix: reset migrate from v5 (#543)
hschoenenberger Sep 1, 2025
27ad49b
[ACCOUNT-3058] feat: manual verification flag (#544)
hschoenenberger Sep 1, 2025
4615105
[ACCOUNT-3078] feat: optimistic set point of contact (#545)
hschoenenberger Sep 4, 2025
2c1d33d
feat: detect url change alert (#540)
hschoenenberger Sep 4, 2025
196aadb
feat: add isVerified status management in CreateIdentityHandler and S…
guillaume60240 Sep 4, 2025
a0c2ad5
[ACCOUNT-3070] Add store name (#546)
antoinemetifeu Sep 4, 2025
5622e00
fix: admin ajax controller alert style (#549)
guillaume60240 Sep 5, 2025
dff567c
fix: preserve bo login session usage (#550)
hschoenenberger Sep 8, 2025
d70e539
fix: cleanup owner session after changing the point of contact (#551)
hschoenenberger Sep 9, 2025
0d280f4
[ACCOUNT-3087] fix: danger banner alert (#552)
hschoenenberger Sep 10, 2025
644c2f8
feat: banner reset link (#553)
hschoenenberger Sep 10, 2025
89e2d17
feat: update readme (#554)
hschoenenberger Sep 11, 2025
d3559e5
refactor: cleanup obsolete abstract rest controller (#555)
hschoenenberger Sep 12, 2025
c06b276
[ACCOUNT-3087] feat: upgrade fail banner ux (#556)
hschoenenberger Sep 15, 2025
e6b91ac
Merge remote-tracking branch 'origin/main' into major/v8
hschoenenberger Sep 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .dir-scoped
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ prestashopcorp/lightweight-container
lcobucci
monolog
ramsey/uuid
phpseclib/phpseclib/phpseclib
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ views/files/*
/views/js/settings*.js.map
/views/js/settingsOnBoarding*.js
/views/js/settingsOnBoarding*.js.map
/views/js/notifications*.js
/views/js/notifications*.js.map
/views/js/login*.js
/views/js/login*.js.map
/views/css/login*.css
Expand Down
1 change: 1 addition & 0 deletions .ver-scoped
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PsAccounts
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,10 @@ phpstan-8.1.5-7.4: platform-8.1.5-7.4 phpstan
PHP_SCOPER_VENDOR_DIRS = $(shell cat .dir-scoped)
PHP_SCOPER_OUTPUT_DIR := vendor-scoped
PHP_SCOPER_VERSION := 0.18.11
PHP_SCOPER_VERSION_PREFIX = $(shell cat .ver-scoped)

php-scoper-version-prefix:
@echo "${PHP_SCOPER_VERSION_PREFIX}"

${WORKDIR}/php-scoper.phar:
curl -s -f -L -O "https://github.com/humbug/php-scoper/releases/download/${PHP_SCOPER_VERSION}/php-scoper.phar"
Expand All @@ -258,13 +262,21 @@ php-scoper-add-prefix: scoper.inc.php vendor-clean vendor ${WORKDIR}/php-scoper.
$(foreach DIR,$(PHP_SCOPER_VENDOR_DIRS), rm -rf "./vendor/${DIR}" && mv "./${PHP_SCOPER_OUTPUT_DIR}/${DIR}" ./vendor/${DIR};)
if [ ! -z ${PHP_SCOPER_OUTPUT_DIR} ]; then rm -rf "./${PHP_SCOPER_OUTPUT_DIR}"; fi

REGEX_UPDATE_PREFIX := "s/PrestaShop\\\\Module\\\\PsAccounts\([0-9]*\)\\\\Vendor/PrestaShop\\\\Module\\\\${PHP_SCOPER_VERSION_PREFIX}\\\\Vendor/"
REGEX_UPDATE_PREFIX2 := "s/PrestaShop\\\\\\\\Module\\\\\\\\PsAccounts\([0-9]*\)\\\\\\\\Vendor/PrestaShop\\\\\\\\Module\\\\\\\\${PHP_SCOPER_VERSION_PREFIX}\\\\\\\\Vendor/"
php-scoper-update-prefix:
@echo "updating prefix..."
find ./tests -type f -exec sed -i -e ${REGEX_UPDATE_PREFIX} {} \;
find ./src -type f -exec sed -i -e ${REGEX_UPDATE_PREFIX} {} \;
sed -i -e ${REGEX_UPDATE_PREFIX2} ./composer.json

php-scoper-dump-autoload:
${COMPOSER} dump-autoload --classmap-authoritative

php-scoper-fix-autoload:
php fix-autoload.php

#php-scoper: php-scoper-add-prefix php-scoper-update-prefix php-scoper-dump-autoload php-scoper-fix-autoload
php-scoper: php-scoper-add-prefix php-scoper-dump-autoload php-scoper-fix-autoload

##########
Expand Down
50 changes: 44 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
# Context

The module **ps_accounts** is the interface between your module and PrestaShop's services. It manages:
- Shop association/dissociation process;
- Shop **Identification** and **Verification** process;
- Providing tokens to communicate safely with PrestaShop services;
- Synchronize basic informations about the shops (ex: shop URLs, name, ...).

This module is a basis for other modules using PrestaShop services.
This module is a base component for other modules using PrestaShop services.

# Installation

Expand All @@ -27,6 +27,7 @@ We aims to follow partially the Prestashop compatibility charts

| ps_accounts version | Prestashop Version | PHP Version |
|----------------------|----------------------|-------------------|
| ^8.0.0 | \>=1.6 && <= 9.x | PHP 5.6 - 8 |
| ^7.0.9 | \>=1.6 && <= 9.x | PHP 5.6 - 8 |
| 7.x | \>=1.6 && <9.x | PHP 5.6 - 8 |
| ~~6.x (deprecated)~~ | ~~\>=8.0.0~~ | ~~PHP 7.2 - 8~~ |
Expand Down Expand Up @@ -70,11 +71,10 @@ Media::addJsDef([

return $this->display(__FILE__, 'views/templates/admin/app.tpl');
```
Alternatively you can still use : [PrestaShop Accounts Installer](http://github.com/PrestaShopCorp/prestashop-accounts-installer) for more details on how to setup Installer.

### Load and init the component on your page

For detailed usage you can follow the component's documentation : [prestashop_accounts_vue_components](https://github.com/PrestaShopCorp/prestashop_accounts_vue_components)
For detailed usage you can follow the component's documentation : [vue-components](https://github.com/PrestaShopCorp/accounts/tree/main/packages/vue-components#readme)

## How to retrieve tokens with PsAccounts

Expand All @@ -91,6 +91,46 @@ This module provides the following tokens:
- **ShopAccessToken** (provided by [Prestashop OpenId Connect Provider](https://oauth.prestashop.com/.well-known/openid-configuration))
For machine to machine calls. (also used to keep up to date legacy Shop and Owner tokens

### How to get shop status

#### Retrieving v8 Shop Status
```php
// /!\ TODO: Starting here you are responsible to check that the module is installed

/** @var Ps_accounts $module */
$module = \Module::getModuleIdByName('ps_accounts');

/** @var \PrestaShop\Module\PsAccounts\Service\PsAccountsService $service */
$service = $module->getService(\PrestaShop\Module\PsAccounts\Service\PsAccountsService::class);

// Starting from v8 status has been split into 3 distinct information
$service->isShopIdentityCreated();
$service->isShopIdentityVerified();
$service->isShopPointOfContactSet();
```

#### Shop status compatibility with v7
```php

// strictly equivalent to:
// service->isShopIdentityCreated() &&
// $service->isShopIdentityVerified() &&
// $service->isShopPointOfContactSet()
$isShopLinked = $service->isAccountLinked();
```

#### Tokens availability with legacy compatibility table

| Method Name | PrestaShop AccessToken | Scopes | **_Legacy_**<br/>Firebase Shop Id Token | **_Legacy_**<br/>Firebase User Id Token |
|-------------------------|------------------------|---------------|-----------------------------------------|-----------------------------------------|
| **_>= v8.0.0_** | | | | |
| isShopIdentityCreated | Yes | | Yes | No |
| isShopIdentityVerified | Yes | shop.verified | Yes | No |
| isShopPointOfContactSet | Yes | shop.verified | Yes | Yes |
| **_< v8.0.0_** | | | | |
| isAccountLinked | Yes | shop.verified | Yes | Yes |


### How to get up-to-date JWT Shop Access Tokens

```php
Expand Down Expand Up @@ -176,8 +216,6 @@ Here are listed custom hooks provided with this module:

| hook | params | description |
|-----------------------------------|------------------|----------------------------------------------|
| actionShopAccountLinkAfter | shopId, shopUuid | Triggered after link shop acknowledged |
| actionShopAccountUnlinkAfter | shopId, shopUuid | Triggered after unlink shop acknowledged |
| actionShopAccessTokenRefreshAfter | token | Triggered after OAuth access token refreshed |

# Building the module locally
Expand Down
89 changes: 62 additions & 27 deletions _dev/apps/configuration/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,53 +17,88 @@
* International Registered Trademark & Property of PrestaShop SA
*-->
<template>
<div id="settingsApp">
<div class="onboarding">
<section class="onboarding-header">
<ConfigInformation />
</section>

<section class="onboarding-content">
<prestashop-accounts></prestashop-accounts>
</section>
</div>
</div>
<PuikTabNavigation :name="args.name" :default-position="args.defaultPosition">
<!-- <PuikTabNavigationGroupTitles :ariaLabel="args.ariaLabel">
<PuikTabNavigationTitle :position="1">
Configuration
</PuikTabNavigationTitle>
<PuikTabNavigationTitle :position="2"> Help </PuikTabNavigationTitle>
</PuikTabNavigationGroupTitles> -->
<PuikTabNavigationGroupPanels>
<PuikTabNavigationPanel :position="1">
<div class="panelContent">
<prestashop-accounts>
<template v-if="!cdnIsLoaded">
<puik-alert variant="danger">Failed to load PrestaShop Account</puik-alert>
</template>
</prestashop-accounts>
</div>
</PuikTabNavigationPanel>
<!-- <PuikTabNavigationPanel :position="2">
<div class="panelContent">
Content for Profile tab goes here.
<p>Profile content goes here.</p>
<p>More profile content can be added here.</p>
</div>
</PuikTabNavigationPanel> -->
</PuikTabNavigationGroupPanels>
</PuikTabNavigation>
</template>

<script setup lang="ts">
import ConfigInformation from "@/configuration/components/ConfigInformation.vue";
import { onMounted } from "vue";
import { init } from "prestashop_accounts_vue_components"
import {
PuikTabNavigation,
PuikTabNavigationGroupTitles,
PuikTabNavigationTitle,
PuikTabNavigationGroupPanels,
PuikTabNavigationPanel, PuikAlert,
} from "@prestashopcorp/puik-components";
import { onMounted, ref } from "vue";

const args = {
name: "PS-Accounts",
defaultPosition: 1,
ariaLabel: "PS-Accounts tabs",
};

const cdnIsLoaded = ref(true);

onMounted(async () => {
if (window?.psaccountsVue) {
return window?.psaccountsVue?.init();
return window?.psaccountsVue?.init(
window.contextPsAccounts.component_params_init,
"Settings",
);
}
init();
cdnIsLoaded.value = false;
});
</script>
<style lang="scss">
#settingsApp {
font-family: Open Sans, Helvetica, Arial, sans-serif;
}
.nobootstrap {
background-color: unset !important;
padding: 100px 10px 100px;
background-color: #ffffff;
padding-top: 100px;
padding-right: 10px;
padding-left: 10px;
min-width: unset !important;
min-height: calc(100vh - 100px) !important;
}

#main {
background-color: #ffffff;
}
.page-sidebar.mobile #content.nobootstrap {
@apply psacc-ml-0;
}
.onboarding {

/* .puik-tab-navigation__group-titles {
border-bottom: rgb(221 221 221) 1px solid;
}
*/
.panelContent {
@apply psacc-pt-24 psacc-max-w-screen-lg psacc-mx-auto;
&-header {
@apply psacc-mb-2;
}
@screen md {
@apply psacc-pt-4;
&-header {
@apply psacc-mb-4;
}
}
}
</style>
16 changes: 15 additions & 1 deletion _dev/apps/configuration/types/window.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
type ContextParamsInit = {
mode: 1 | 2 | 4;
shopId: number;
groupId: number;
getContextUrl: string;
manageAccountUrl: string;
token: string;
psxName: string;
}

interface Window {
psaccountsVue: any;
signInComponent: any;
storePsAccounts: any;
}
contextPsAccounts: {
[key: string]: any;
component_params_init: ContextParamsInit;
};
}
53 changes: 53 additions & 0 deletions _dev/apps/notifications/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
document.addEventListener('DOMContentLoaded', async function() {
function getParams() {
const scriptFilename = 'ps_accounts/views/js/notifications.js';
const scripts = document.querySelectorAll('script');

let currentScript: HTMLScriptElement|null = null;
scripts.forEach(script => {
if (script.src.includes(scriptFilename)) {
currentScript = script;
}
});

if (currentScript) {
// Get the full URL of the script
const scriptSrc = currentScript['src'];
const url = new URL(scriptSrc);

return url.searchParams;
}
return null;
}

async function getNotifications(uri: string) {
return await fetch(uri, {
method: 'GET'
})
.then(response => response.json())
.then(data => {
return data;
})
.catch(error => {
console.error('Error:', error);
return null;
});
}

function injectNotifications(notifications: [], container: Element)
{
notifications.forEach((notif: any) => {
const alert = document.createElement('div');
alert.innerHTML = notif?.html;
container.prepend(alert);
});
}

const container = document.querySelector('#main-div .content-div, #main #content');
if (! container) return;

const params = getParams();
if (!params) return;

injectNotifications(await getNotifications(params.get('ctx') || ''), container);
});
2 changes: 1 addition & 1 deletion _dev/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>
</html>
6 changes: 3 additions & 3 deletions _dev/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"name": "ps_accounts",
"version": "7.2.2",
"version": "8.0.0",
"private": true,
"scripts": {
"dev": "vite",
"build": "vue-tsc --noEmit && vite build && vite build --config=vite.login.config.ts",
"build": "vue-tsc --noEmit && vite build && vite build --config=vite.login.config.ts && vite build --config=vite.notifications.config.ts",
"build:vue": "vue-tsc --noEmit && vite build",
"build:login": "vite build --config=vite.login.config.ts",
"build:notifications": "vite build --config=vite.notifications.config.ts",
"lint": "eslint --ext .js,.ts,.vue .",
"lint:fix": "eslint --ext .js,.ts,.vue . --fix"
},
Expand All @@ -16,7 +17,6 @@
"@prestashopcorp/puik-resolver": "^2.0.1",
"@prestashopcorp/puik-tailwind-preset": "^2.2.0",
"@splidejs/splide": "^4.1.4",
"prestashop_accounts_vue_components": "^5.3.0",
"vue": "^3.5.13",
"vue-i18n": "^11.1.0",
"zoid": "9.0.86"
Expand Down
Loading