Comparing version 0.0.11 to 0.0.13
42
index.js
@@ -25,3 +25,5 @@ var portalPostMessage; | ||
getEventData: onGetEventData, | ||
setBarTitle: onSetBarTitle | ||
setBarTitle: onSetBarTitle, | ||
setStorage: onSetStorage, | ||
getStorage: onGetStorage | ||
}; | ||
@@ -219,2 +221,38 @@ | ||
function onSetStorage({ key, value }) { | ||
switch (platform) { | ||
case PLATFORM_WEB_PORTAL: | ||
portalPostMessage({ | ||
action: 'SET_COOKIE', | ||
type: key, | ||
message: value, | ||
}) | ||
break; | ||
} | ||
} | ||
function onGetStorage({ key, success, fail }) { | ||
switch (platform) { | ||
case PLATFORM_WEB_PORTAL: | ||
portalPostMessage({ | ||
action: 'GET_COOKIE', | ||
type: key, | ||
}) | ||
window.addEventListener('message', function (event) { | ||
if (typeof event.data !== 'string') return; | ||
if (event.data.startsWith("{") && !event.data.startsWith("setImmediate")) { | ||
const x = JSON.parse(event.data); | ||
switch (x.action) { | ||
case "GET_COOKIE": | ||
success({ data: x.data }); | ||
break; | ||
} | ||
return; | ||
} | ||
}, false); | ||
break; | ||
} | ||
} | ||
export default { | ||
@@ -237,2 +275,4 @@ getSignedRequest: onPrepareSignedRequest, | ||
setBarTitle: onSetBarTitle, | ||
setStorage: onSetStorage, | ||
getStorage: onGetStorage, | ||
PLATFORM_MOBILE_APP, | ||
@@ -239,0 +279,0 @@ PLATFORM_TERMINAL, |
@@ -32,3 +32,5 @@ "use strict"; | ||
getEventData: onGetEventData, | ||
setBarTitle: onSetBarTitle | ||
setBarTitle: onSetBarTitle, | ||
setStorage: onSetStorage, | ||
getStorage: onGetStorage | ||
}; // util for sleep | ||
@@ -332,2 +334,49 @@ | ||
function onSetStorage(_ref8) { | ||
var key = _ref8.key, | ||
value = _ref8.value; | ||
switch (platform) { | ||
case PLATFORM_WEB_PORTAL: | ||
portalPostMessage({ | ||
action: 'SET_COOKIE', | ||
type: key, | ||
message: value | ||
}); | ||
break; | ||
} | ||
} | ||
function onGetStorage(_ref9) { | ||
var key = _ref9.key, | ||
success = _ref9.success, | ||
fail = _ref9.fail; | ||
switch (platform) { | ||
case PLATFORM_WEB_PORTAL: | ||
portalPostMessage({ | ||
action: 'GET_COOKIE', | ||
type: key | ||
}); | ||
window.addEventListener('message', function (event) { | ||
if (typeof event.data !== 'string') return; | ||
if (event.data.startsWith("{") && !event.data.startsWith("setImmediate")) { | ||
var x = JSON.parse(event.data); | ||
switch (x.action) { | ||
case "GET_COOKIE": | ||
success({ | ||
data: x.data | ||
}); | ||
break; | ||
} | ||
return; | ||
} | ||
}, false); | ||
break; | ||
} | ||
} | ||
var _default = { | ||
@@ -350,2 +399,4 @@ getSignedRequest: onPrepareSignedRequest, | ||
setBarTitle: onSetBarTitle, | ||
setStorage: onSetStorage, | ||
getStorage: onGetStorage, | ||
PLATFORM_MOBILE_APP: PLATFORM_MOBILE_APP, | ||
@@ -352,0 +403,0 @@ PLATFORM_TERMINAL: PLATFORM_TERMINAL, |
{ | ||
"name": "rm-plugin", | ||
"version": "0.0.11", | ||
"version": "0.0.13", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "description": "", |
@@ -66,2 +66,16 @@ # RM Plugin SDK <img alt="npm" src="https://img.shields.io/npm/v/rm-plugin"> | ||
// set storage by key and value | ||
rm.setStorage({ | ||
key: 'test', | ||
value: 'token', | ||
}) | ||
// get storage by key name | ||
rm.getStorage({ | ||
key: 'test', | ||
success: function({ data }) { | ||
console.log("content", data); | ||
} | ||
}) | ||
``` |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
23510
591
80
1