Skip to content

Commit

Permalink
Merge pull request #565 from commercelayer/docs-update-js-auth
Browse files Browse the repository at this point in the history
Update `js-auth` library in the documentation package
  • Loading branch information
gciotola authored Aug 1, 2024
2 parents 79f8c4b + 863f45f commit b1e3213
Show file tree
Hide file tree
Showing 3 changed files with 178 additions and 215 deletions.
6 changes: 3 additions & 3 deletions packages/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"@babel/core": "^7.23.9",
"@babel/preset-env": "^7.23.9",
"@commercelayer/eslint-config-ts-react": "^1.3.0",
"@commercelayer/js-auth": "^4.2.1",
"@commercelayer/sdk": "^5.32.0",
"@commercelayer/js-auth": "^6.3.1",
"@commercelayer/sdk": "^6.9.0",
"@mdx-js/react": "^3.0.1",
"@storybook/addon-actions": "^7.6.17",
"@storybook/addon-backgrounds": "^7.6.17",
Expand All @@ -30,7 +30,7 @@
"@storybook/testing-library": "^0.2.2",
"@storybook/theming": "^7.6.17",
"@types/js-cookie": "^3.0.6",
"@types/react": "^18.2.57",
"@types/react": "^18.3.3",
"@vitejs/plugin-react": "^4.2.1",
"babel-loader": "^9.1.2",
"eslint": "^8.56.0",
Expand Down
12 changes: 5 additions & 7 deletions packages/docs/stories/_internals/useGetToken.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { authentication } from '@commercelayer/js-auth'
import { authenticate } from '@commercelayer/js-auth'
import { useEffect, useMemo, useState } from 'react'
import Cookie from 'js-cookie'
import { type TBaseReturn } from '@commercelayer/js-auth/lib/esm/types'
import { jwtDecode } from 'jwt-decode'

const salesChannel = {
Expand Down Expand Up @@ -142,6 +141,7 @@ async function retrieveCustomerData({
}
}

// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
async function generateNewToken({
clientId,
slug,
Expand All @@ -156,17 +156,15 @@ async function generateNewToken({
domain: string
user?: { username: string; password: string }
mode: UserMode
}): Promise<TBaseReturn> {
}) {
return user == null
? await authentication('client_credentials', {
? await authenticate('client_credentials', {
clientId,
slug,
scope,
domain
})
: await authentication('password', {
: await authenticate('password', {
clientId,
slug,
scope,
domain,
...user
Expand Down
Loading

0 comments on commit b1e3213

Please sign in to comment.