Skip to content

Commit

Permalink
👽 Using new SAM token endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
mariush2 committed Dec 17, 2024
1 parent 219b448 commit 01e4a95
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 25 deletions.
Binary file modified bun.lockb
Binary file not shown.
11 changes: 1 addition & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@
"last 1 safari version"
]
},
"dependencies": {
"@azure/msal-browser": "3.26.1",
"@azure/msal-react": "2.1.1",
"jwt-decode": "^4.0.0"
},
"devDependencies": {
"@faker-js/faker": "^9.0.3",
"@rollup/plugin-commonjs": "^28.0.1",
Expand Down Expand Up @@ -113,14 +108,10 @@
"vitest": "^2.1.3"
},
"peerDependencies": {
"@equinor/eds-core-react": "*",
"@equinor/eds-icons": "*",
"@tanstack/react-query": "*",
"framer-motion": "*",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router": "^6.11.1",
"react-router-dom": "^6.11.1",
"styled-components": "^6.1.8"
"react-router-dom": "^6.11.1"
}
}
24 changes: 23 additions & 1 deletion src/api/core/OpenAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,28 @@ export class TokenService {
url: '/api/v1/Token/AmplifyPortal/Production',
});
}

/**
* @returns string Success
* @throws ApiError
*/
public static getSamPortalToken(): CancelablePromise<string> {
return __request(OpenAPI_APP, {
method: 'GET',
url: '/api/v1/Token/SamPortal',
});
}

/**
* @returns string Success
* @throws ApiError
*/
public static getSamPortalProductionToken(): CancelablePromise<string> {
return __request(OpenAPI_APP, {
method: 'GET',
url: '/api/v1/Token/SamPortal/Production',
});
}
}

const isJwtTokenExpired = (token: string) => {
Expand Down Expand Up @@ -99,7 +121,7 @@ const getJSEmbarkProdToken = async () => {
};

export const getSAMToken = async (): Promise<string> => {
return getToken(`sam-${environmentName}`, TokenService.getAmplifyPortalToken);
return getToken(`sam-${environmentName}`, TokenService.getSamPortalToken);
};

const getSAMProdToken = async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/* eslint-disable */
export { ApiError } from './core/ApiError';
export { CancelablePromise, CancelError } from './core/CancelablePromise';
export { OpenAPI_APP, getJSEmbarkToken } from './core/OpenAPI';
export { OpenAPI_APP, getJSEmbarkToken, getSAMToken } from './core/OpenAPI';
export { request } from './core/request';
export type { OpenAPIConfig } from './core/OpenAPI';

Expand Down
16 changes: 3 additions & 13 deletions src/providers/providers.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
import { Typography } from '@equinor/eds-core-react';
import { Meta } from '@storybook/react';

import styled from 'styled-components';

const providersList = [
{
name: 'AuthProvider',
body: 'MSAL authentication provider',
code: `<AuthProvider
loadingComponent={component to show when loading}
unauthorizedComponent={componentToShowWhenUnauthorized}>
{children}
</AuthProvider>`,
},
{
name: 'TutorialStepsProvider',
body: 'Provider needed to use tutorial hook',
Expand Down Expand Up @@ -64,14 +54,14 @@ const Divider = styled.hr`
export const Docs = () => (
<Container>
<div>
<Typography variant="h1">List of all providers</Typography>
<h1>List of all providers</h1>
<Divider />
</div>
{providersList.map((provider) => (
<Content key={provider.name}>
<div>
<Typography variant="h3">{provider.name}</Typography>-
<Typography>{provider.body}</Typography>
<h3>{provider.name}</h3>-
<p>{provider.body}</p>
</div>
<code>{provider.code}</code>
</Content>
Expand Down

0 comments on commit 01e4a95

Please sign in to comment.