Skip to content

Commit

Permalink
MI-121: fix fomatting of release-notes.md file.
Browse files Browse the repository at this point in the history
Update the getBcCustomerIdFromMeshToken function to look for a bc_customer_id but comment as deprected to make the fix backwards compatible.
  • Loading branch information
brettcutt-aligent committed Nov 27, 2024
1 parent 2a99d81 commit a6e5fb1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
7 changes: 2 additions & 5 deletions packages/modules/bigcommerce/release-notes.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
# BigCommerce GraphQl Module Release Notes

## bigcommerce-graphql-module-1.0.8
## bigcommerce-graphql-module-1.1.0

#### Changes:

- Updates the "generateMeshToken" function to return a "customer_id" property instead of "bc_customer_id".
Updates the "getBcCustomerIdFromMeshToken" function to look for a "customer_id" property instead of "bc_customer_id".
This is due to the Auth Module generating a JWT containing a "customer_id" property
but the BigCommerce Module decodes the JWT and looks for a "bc_customer_id" property.
- Updates the "generateMeshToken" function to return a "customer_id" property instead of "bc_customer_id". Updates the "getBcCustomerIdFromMeshToken" function to look for a "customer_id" property instead of "bc_customer_id". This is due to the Auth Module generating a JWT containing a "customer_id" property but the BigCommerce Module decodes the JWT and looks for a "bc_customer_id" property.

#### Tickets

Expand Down
2 changes: 2 additions & 0 deletions packages/modules/bigcommerce/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ export interface DecodedCustomerImpersonationToken {
}

export interface MeshToken {
/* @deprecated since v1.0.1. Use "customer_id" instead */
bc_customer_id: number;
customer_id: number;
iat: number;
exp: number;
Expand Down
6 changes: 5 additions & 1 deletion packages/modules/bigcommerce/src/utils/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ export const getBcCustomerIdFromMeshToken = (meshToken: string): number => {
if (meshToken?.toLowerCase().startsWith('bearer')) {
const splitMeshToken = meshToken.split(' ')[1];
const decodedMeshToken = verify(splitMeshToken, JWT_PRIVATE_KEY) as MeshToken;
return decodedMeshToken.customer_id;

/* @deprecated since v1.0.1. Use "customer_id" instead of "bc_customer_id" */
return decodedMeshToken.customer_id || decodedMeshToken.bc_customer_id;
} else {
throw new Error(`Need to send Bearer token`);
}
Expand All @@ -54,6 +56,8 @@ export const getBcCustomerIdFromMeshToken = (meshToken: string): number => {
*/
export const generateMeshToken = (entityId: number): string => {
const payload = {
/* @deprecated since v1.0.1. Use "customer_id" instead */
bc_customer_id: entityId,
customer_id: entityId,
exp: getUnixTimeStampInSecondsForMidnightTonight(),
};
Expand Down

0 comments on commit a6e5fb1

Please sign in to comment.