-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add an helper to decode the JWT
- Loading branch information
1 parent
5da8de6
commit ad98ce2
Showing
8 changed files
with
483 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
// @ts-check | ||
|
||
import { authenticate } from '@commercelayer/js-auth' | ||
import { authenticate, jwtDecode, jwtIsSalesChannel } from '@commercelayer/js-auth' | ||
|
||
async function run() { | ||
const auth = await authenticate('client_credentials', { | ||
clientId: 'BISG8bb3GWpC8_D7Nt1SuWWdieS5bJq831A50LgB_Ig', | ||
scope: 'market:id:KoaJYhMVVj' | ||
}) | ||
const auth = await authenticate('client_credentials', { | ||
clientId: 'BISG8bb3GWpC8_D7Nt1SuWWdieS5bJq831A50LgB_Ig', | ||
scope: 'stock_location:id:DGzAouppwn' | ||
}) | ||
|
||
console.log(auth) | ||
} | ||
console.log(auth) | ||
|
||
const parsedJWT = jwtDecode(auth.accessToken) | ||
|
||
run() | ||
if (jwtIsSalesChannel(parsedJWT.payload)) { | ||
console.log(parsedJWT.payload) | ||
} |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
export { authenticate } from './authenticate.js' | ||
export { | ||
jwtDecode, | ||
jwtIsDashboard, | ||
jwtIsIntegration, | ||
jwtIsProvisioning, | ||
jwtIsSalesChannel, | ||
jwtIsWebApp | ||
} from './jwtDecode.js' | ||
|
||
export type { | ||
GrantType, | ||
AuthenticateOptions, | ||
AuthenticateReturn | ||
AuthenticateReturn, | ||
GrantType | ||
} from './types/index.js' |
Oops, something went wrong.