UNPKG

@equinor/mad-core

Version:

Core library for the Mobile App Delivery team

48 lines (45 loc) 1.87 kB
import { getMadCommonBaseUrl, getMadCommonScopes } from "./chunk-ZB37EIZB.js"; import { getConfig } from "./chunk-GEEFQMRN.js"; import { __async } from "./chunk-CWMXXUWU.js"; // src/components/screens/release-notes/fetchReleaseNotes.ts import { authenticateSilently, ExpoAuthSession } from "@equinor/mad-auth"; var fetchReleaseNotes = (env, servicePortalName, appVersion) => __async(void 0, null, function* () { var _a; const scopes = getMadCommonScopes(env); const baseUrl = getMadCommonBaseUrl(env); const authenticationResponse = ((_a = getConfig().experimental) == null ? void 0 : _a.useExpoAuthSession) ? yield ExpoAuthSession.authenticateSilently(scopes) : yield authenticateSilently(scopes); if (!authenticationResponse) throw new Error("Unable to authenticate silently"); const fetchResponse = yield fetch(`${baseUrl}/ReleaseNote/${servicePortalName}/${appVersion}`, { method: "GET", headers: new Headers({ Authorization: `Bearer ${authenticationResponse.accessToken}` }) }); return yield fetchResponse.json(); }); var fetchAllReleaseNotes = (env, servicePortalName) => __async(void 0, null, function* () { var _a; const scopes = getMadCommonScopes(env); const baseUrl = getMadCommonBaseUrl(env); const authenticationResponse = ((_a = getConfig().experimental) == null ? void 0 : _a.useExpoAuthSession) ? yield ExpoAuthSession.authenticateSilently(scopes) : yield authenticateSilently(scopes); if (!authenticationResponse) throw new Error("Unable to authenticate silently"); const fetchResponse = yield fetch(`${baseUrl}/ReleaseNote/${servicePortalName}/`, { method: "GET", headers: new Headers({ Authorization: `Bearer ${authenticationResponse.accessToken}` }) }); const result = yield fetchResponse.json(); return result; }); export { fetchReleaseNotes, fetchAllReleaseNotes };