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

@livecycle/sdk

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@livecycle/sdk - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

66

dist/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LivecycleSdk = void 0;
var sdk_1 = require("./sdk");
Object.defineProperty(exports, "LivecycleSdk", { enumerable: true, get: function () { return sdk_1.default; } });
(() => {
// src/sdk/script-loader.ts
var injectAgentScript = (doc) => (dep) => {
const script = doc.createElement("script");
if (dep.scriptType) {
script.type = dep.scriptType;
}
script.id = dep.agentScriptId;
script.src = dep.agentSrc;
const prom = new Promise((resolve, reject) => {
script.addEventListener("load", () => resolve());
script.addEventListener("error", reject);
});
doc.head.appendChild(script);
return prom;
};
var checkAgentScriptExist = (doc) => (dep) => {
const script = doc.getElementById(dep.agentScriptId);
return script?.id === dep.agentScriptId;
};
var loadScript = (doc) => async (dep) => {
const agentScriptExist = checkAgentScriptExist(doc)(dep);
if (agentScriptExist) {
throw new Error(
"Livecycle agent script already injected, this may be due to multiple initialization"
);
}
return await injectAgentScript(doc)(dep);
};
// src/sdk/index.ts
var Configs = {
agentSrc: "https://livecycle.dev/agent.js",
agentScriptId: "lc__agent",
scriptType: "module"
};
function registerSDKValidateHandler() {
window?.addEventListener("message", (e) => {
if ("type" in e.data && e.data.type === "livecycle-sdk-check") {
e.source?.postMessage(
{
type: "livecycle-sdk-check-response"
},
{
targetOrigin: e.origin
}
);
}
});
}
var Livecycle = {
async init(userConfigs = {}) {
try {
registerSDKValidateHandler();
await loadScript(document)(Configs);
} catch (e) {
console.debug("failed to init livecycle-agent", e);
}
}
};
var sdk_default = Livecycle;
})();

4

dist/sdk/script-loader.d.ts
export declare const injectAgentScript: (doc: Document) => (dep: {
agentSrc: string;
agentScriptId: string;
scriptType?: 'module';
scriptType?: "module";
}) => Promise<void>;

@@ -12,3 +12,3 @@ export declare const checkAgentScriptExist: (doc: Document) => (dep: {

agentScriptId: string;
scriptType?: 'module';
scriptType?: "module";
}) => Promise<void>;
{
"name": "@livecycle/sdk",
"version": "0.1.4",
"version": "0.1.5",
"description": "livecycle sdk",

@@ -30,6 +30,7 @@ "author": "livecycle",

"tslib": "^2.3.1",
"typescript": "^4.4.3"
"typescript": "^4.4.3",
"esbuild": "^0.15.14"
},
"scripts": {
"build": "shx rm -rf dist && tsc -b",
"build": "esbuild ./src/sdk/index.ts --bundle --outfile=./dist/index.js && tsc --emitDeclarationOnly",
"lint": "eslint . --ext .ts --config .eslintrc",

@@ -36,0 +37,0 @@ "posttest": "yarn lint",

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