npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@atlaskit/atlassian-context

v0.0.2

Published

Provides FedRAMP-friendly URLs and helps to identify if product is running in FedRAMP environment.

Downloads

519,018

Readme

Environment context library

Provides FedRAMP-friendly URLs and helps to identify if product is running in FedRAMP environment.

Read more about it here: https://hello.atlassian.net/wiki/spaces/FEDRAMP/pages/2561199256/UI+Isolation

Installation

npm install @atlaskit/atlassian-context --save

Prerequisites

In order for @atlaskit/atlassian-context to work correctly window.ATL_CONTEXT_DOMAIN has to be set on the page. Products must either have the data already on window or call configure(), before calling any get*() calls. Otherwise getATLContextDomain() and getATLContextUrl() will use fallbacks and potentially return an uncorrected response.

If using the deprecated isFedRamp() method, also window.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.

Setup

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.

Server Generated HTML

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:

<!-- Assuming your Java service has loaded the appropriate configuration into $domain_config -->

<script nonce="$nonce">
	window.ATL_CONTEXT_DOMAIN = $domain_config.stringify();
</script>

<!-- Assuming your Java service has loaded the micros perimeter into $micros_perimeter.
    NOTE: Only needed if your service uses the isFedRamp function
  -->
<script nonce="nonce">
	window.UNSAFE_ATL_CONTEXT_BOUNDARY = $micros_perimeter.stringify();
</script>

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.

Serverless

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

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(<YourApp />, element)
}

If your application is rendered through React SSR, you should ensure you will need to manually invoke the configure() function with the provided data.

API

configure()

Takes the data, and stores in window.ATL_CONTEXT_DOMAIN for later use.

getATLContextDomain()

Returns the domain for a given Atlassian service. It relies on window.ATL_CONTEXT_DOMAIN be present on the page, in case window.ATL_CONTEXT_DOMAIN is undefined getATLContextDomain() will try to retrieve the value from a list of hardcoded domains, which could be not up to date. The fallback relies on window.UNSAFE_ATL_CONTEXT_BOUNDARY be present on the page, if undefined getATLContextDomain() will fallback to non-fedramp (commercial) value.

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

getATLContextUrl()

Returns the full url for a given Atlassian service. Being based off getATLContextDomain, it relies on window.ATL_CONTEXT_DOMAIN 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.

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

isFedRamp()

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 on window.UNSAFE_ATL_CONTEXT_BOUNDARY be present on the page, in case window.UNSAFE_ATL_CONTEXT_BOUNDARY is undefined it will try to identify the environment based on the site domain, eventually fallback to false.

import { isFedRamp } from '@atlaskit/atlassian-context';

if (isFedRamp()) {
	// your specific logic here
}