Provides perimeter-specific URL resolution and helps identify which environment a product is running in.
npm install @atlaskit/atlassian-contextProvides perimeter-specific URL resolution and helps identify which environment a product is running in.
Read more about the original considerations here:
https://hello.atlassian.net/wiki/spaces/FEDRAMP/pages/2561199256/UI+Isolation
``sh`
npm install @atlaskit/atlassian-context --save
> _NOTE:_ Skip these pre-requisites if onboarding onto library for the first time in May 2025 onwards. These pre-requisites are for the original configure(), getATLContextDomain(), getATLContextUrl(), and isFedRamp() functions, which be will be deprecated in the nearish future.
In order for @atlaskit/atlassian-context to work correctly window.ATL_CONTEXT_DOMAIN has to beconfigure()
set on the page. Products must either have the data already on window or call , beforegetATLContextDomain()
calling any get\*() calls. Otherwise and getATLContextUrl() will use
fallbacks and potentially return an uncorrected response.
If using the deprecated isFedRamp() method, alsowindow.UNSAFE_ATL_CONTEXT_BOUNDARY = 'fedramp-moderate' | 'commercial' has to be set on the page.
Otherwise, you could potentially serve environments with code that it is not relevant to them.
> _NOTE:_ Skip this setup if onboarding onto library for the first time in May 2025 onwards. Access to window.ATL_CONTEXT_DOMAIN and window.UNSAFE_ATL_CONTEXT_BOUNDARY is only required for the configure(), getATLContextDomain(), getATLContextUrl(), and isFedRamp() functions, which be will be deprecated in the nearish future.
This library must be initialised in order to return the correct results. How it gets initialised
will depend on your service. The configuration data may be loaded by any Micros service from
Config Registry. For any further help,
reach out to #help-config-injector.
**⚠️ Warning: window.MICROS_PERIMETER will be replaced by window.UNSAFE_ATL_CONTEXT_BOUNDARY in
future iterations - see go-is-fedramp.**
- window.MICROS_PERIMETER - see go-is-fedramp \*
_Recommended_
If your service always generates static HTML, you can leverage window context to correctly configure
this library. Consider this Velocity template snippet as an example:
`html
`
The library will automatically initialise with this configuration if the variable is found. If the
config isn’t available it will use fallbacks and potentially return uncorrected values.
_Discourage: This will regress your apps performance. Your page is no longer serverless, due to its
requirement for FedRAMP config. You should move to server-based hosting._
Before render, you must fetch the data
`js
import { configure } from '@atlaskit/atlassian-context';
function init(){
// get the config from globaledge
const data = await fetch('https://my.backend.api/_config/domains');
// tell @atlaskit/atlassian-context about it
configure(data)
// and only then run other code / render your page
ReactDOM.render(
}
`
If your application is rendered through React SSR, you should ensure you will need to manually
invoke the configure() function with the provided data.
_Disclaimer:_ This does not need to be invoked for the isFedrampModerate(), isIsolatedCloud(), isolatedCloudDomain(), isolationContextId(), getDomainInContext(...), and getUrlForDomainInContext(...) functions.
Takes the data, and stores in window.ATL_CONTEXT_DOMAIN for later use.
_Disclaimer:_ Please use getDomainInContext(subdomain, environment) instead of this function, as the deprecation process for this function will begin in the near future.
Returns the domain for a given Atlassian service. It relies on window.ATL_CONTEXT_DOMAIN bewindow.ATL_CONTEXT_DOMAIN
present on the page, in case is undefined getATLContextDomain() willwindow.UNSAFE_ATL_CONTEXT_BOUNDARY
try to retrieve the value from a list of hardcoded domains, which could be not up to date. The
fallback relies on be present on the page, if undefinedgetATLContextDomain() will fallback to non-fedramp (commercial) value.
`js
import { getATLContextDomain } from '@atlaskit/atlassian-context';
getATLContextDomain('jira'); // jira.atlassian.com OR jira.atlassian-fex.com depending based on environment
getATLContextDomain('confluence'); // confluence.atlassian.com
getATLContextDomain('admin'); // admin.atlassian.com OR admin.atlassian-fex.com
`
_Disclaimer:_ Please use getUrlForDomainInContext(subdomain, environment) instead of this function, as the deprecation process for this function will begin in the near future.
Returns the full url for a given Atlassian service. Being based off getATLContextDomain, itwindow.ATL_CONTEXT_DOMAIN
relies on be present on the page, otherwise getATLContextDomain will
try to retrieve the value from a list of hardcoded domains, which could be not up to date and
potentially fallback to non-fedramp (commercial) value.
getATLContextUrl() detects browser protocol (http/https) and applies it to domain.
`js
import { getATLContextUrl } from '@atlaskit/atlassian-context';
getATLContextUrl('jira'); // https://jira.atlassian.com OR https://jira.atlassian-fex.com depending based on environment
getATLContextUrl('confluence'); // https://confluence.atlassian.com
getATLContextUrl('admin'); // https://admin.atlassian.com OR https://admin.atlassian-fex.com
`
_Disclaimer:_ Please use isFedrampModerate() instead of this function, as the deprecation process for this function will begin in the near future.
_Caution: Consider Alternatives_ Use of this function is not recommended as a long term solution, as
it creates an assumption there are no other isolated environments than just FedRAMP Moderate. You
are encouraged to consider alternate solutions, such as Statsig or environment configuration, that
don’t require creating a hard dependency between your code features and the FedRAMP environment -
see go-is-fedramp
Returns whether the service is deployed in the FedRAMP boundary. isFedRamp() relies onwindow.UNSAFE_ATL_CONTEXT_BOUNDARY be present on the page, in casewindow.UNSAFE_ATL_CONTEXT_BOUNDARY is undefined it will try to identify the environment based on
the site domain, eventually fallback to false.
`js
import { isFedRamp } from '@atlaskit/atlassian-context';
if (isFedRamp()) {
// your specific logic here
}
`
. If the current perimeter is not an L2 IC (ex. the current fedramp-moderate or regular commercial), then undefined is returned.
$3
Returns the current isolation context identifier (ex: ic-123). If the current perimeter is not an L2 IC (such as if the perimeter is fedramp-moderate or regular commercial), then undefined is returned.$3
Returns the full domain (including support for Isolation Cloud) for a given Atlassian service or experience. Important: Note that the library currently does NOT guarantee that the requested domain exists! It is assumed that when a user requests the full domain for a specific service, they already know the domain exists.
Parameters:
*
subdomain is a required parameter. This should be the service or Atlassian experience for which the full domain is being requested.*
environment is a required parameter. This should be one of dev, staging, or prod.
#### Non-Isolated Cloud Details:
For Non-Isolated Cloud (ex. fedramp-moderate and regular commercial), the perimeter and environment values will be used to create and return the expected domain.
Exceptions to this are stored in the fullDomainOverride definitions. If you require a URL Mapping that is inconsistent between perimeters and environments, then you should add an entry to
domains.tsx.Examples:
When called in fedramp-moderate:
`js
import { getDomainInContext } from '@atlaskit/atlassian-context';getDomainInContext('id', 'staging') // returns "id.stg.atlassian-us-gov-mod.com" (id has a full domain override)
getDomainInContext('analytics', 'staging') // returns "analytics.atlassian.com" because
analytics is a non-varying global domain
getDomainInContext('nonexistent-service', 'staging') // returns "nonexistent-service.stg.atlassian-us-gov-mod.com"
`When called in (non-isolated) commercial:
`js
import { getDomainInContext } from '@atlaskit/atlassian-context';getDomainInContext('id', 'prod') // returns "id.atlassian.com"
getDomainInContext('analytics', 'prod') // returns "analytics.atlassian.com"
`#### Isolated Cloud Details:
For Oasis, one of three domain types are returned: a Reserved Name domain, a namespace subdomain, or an Atlassian services subdomain (see RFC).
Reserved names and the namespace subdomains are temporarily being configured in the ReservedNameMapping and AtlDomainMapping definitions. If a new name has been registered under one of these categories, please raise a PR to update the relevant mapping.
Precedence is as follows: reserved name pattern > namespace pattern > default to the services pattern.
Example:
When called in (isolated) commercial:
`js
import { getDomainInContext } from '@atlaskit/atlassian-context';getDomainInContext('id') // returns "id.."
getDomainInContext('packages') // returns "packages.atl.."
getDomainInContext('new-service') // returns "new-service.services.."
`$3
Returns the full url a given Atlassian service (including support for Isolation Cloud) by appending the current URL scheme to the result of getDomainInContext(subdomain, environment).`js
import { getUrlForDomainInContext } from '@atlaskit/atlassian-context';getUrlForDomainInContext('design', 'staging') // --> returns "https://design.atlassian.com"
``