New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bifrost-cors

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bifrost-cors

A cross-domain utility lib, for sharing localStorage, cookie and many more over the cross domain

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
103
increased by80.7%
Maintainers
1
Weekly downloads
 
Created
Source

Bifrost-CORS

A cross-domain communication solution to share data and many more functionalities with simple as just calling a method.
Get Started
NPM Install

npm install bifrost-cors

https://cdn.jsdelivr.net/gh/spurushottam13/bifrost-cors/index.min.js

GZIP version of File (1.7KB)

https://cdn.jsdelivr.net/gh/spurushottam13/bifrost-cors/index.min.gz

Functionalities can be performed on CROS Domain

All above methods are wrapped in a promise.


Initialize Bifrost-CORS You have to Initialize Bifrost-CORS in both domain
var bifrostCors = new bifrostCors(address, iframeBoolean,iframeId)	
ParameterRequiredValue
addressYESExact Address of the other domain
iframeBooleanNotrue :- If you already rendering the other domain in iframe
false If you are not rendering the other domain in iframe
Default false
iframeIdNoif iframeBoolean is set to true then you need to pass the ID for your Iframe in which you loading the other domain

Implementation of methods and how to handle promise
var bifrostCors = new bifrostCors("http://example.com/",false)

//Calling Methods without promise
var result = bifrostCors.getLocalStorage(key)

//Hanlde Promise

//1. Using .then()
bifrostCors.getLocalStorage(key).then((data) => {
	console.log(data)
 })

//2. Using async function
async function grabLocalStorage(){
	let result = await  bifrostCors.getLocalStorage(key)
}

Functionalities
  • Cookies

    • Get Cookies
    // return type Object, return all cookies
    bifrostCors.getCookie() 
    
    // return type string
    bifrostCors.getCookie("key")
    
    • Set Cookies
    bifrostCors.setCookie(name,value,days)   
    
    • Parameter
      • name String, name for cookie
      • value String, value for cookie
      • days int, expiration days for cookie
    • return type Boolean
  • LocalStorage

    • Get local Storage
    // return type stirng
    bifrostCors.getgetLocalStorage("key") 
    
    // return type array
    bifrostCors.getLocalStorage(["key1","key2"])
    
    • Set local Storage
    // return type Boolean
    bifrostCors.setLocalStorage({key: "user", value: "user-1"}) 
    
    • Delete local Storage
    // return type Boolean
    bifrostCors.deleteLocalStorage("key") 
    
    // return type Boolean
    bifrostCors.deleteLocalStorage(["key1","key2"])
    
  • Bi-directional message thread

    • Request Message Thread
    // return type Boolean, parameter type funtion
    bifrostCors.requestMessageThread(Listner)
    

    Listner is your custom function which will be invoked every time new message recivied, and it should expect a new message as a parameter

    Here's exapmle

    function myCustomListner(newMessage){
    	cosnole.log("Hurray I got new message ",newMessage)
     }
     
     bifrostCors.requestMessageThread(myCustomListner)
    
    • Send Message
    // return type Boolean, parameter type string|int|array|object
    bifrostCors.send(message)
    
  • Run JS expression

    // return type Boolean, parameter type string
    bifrostCors.runExpression(expression)
    
  • DOM Manipulation

    • DOM Manipulation by ID
    // return type Boolean, parameter type string
    bifrostCors.domManipulationById("yourElementID")
    
    • DOM Manipulation by class name
    // return type Boolean, parameter type string,int,Objet
    bifrostCors.domManipulationById(class,index,style)
    
    • Parameter
      • class String your element class name
      • index int index no of that element in class array
      • style Object Style object
    • Example:a if you can access element by document.getElementsByClassName("myElementClass)[4]
      so parameter will be
      • class "myElementClass"
      • index 4
      • style {background:"red"}

Keywords

FAQs

Package last updated on 18 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc