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

@dialectlabs/actions-ui

Package Overview
Dependencies
Maintainers
5
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dialectlabs/actions-ui - npm Package Compare versions

Comparing version 0.1.0-beta.8 to 0.1.0-beta.9

dist/chunk-JA56SRE5.cjs

10

dist/ext/twitter.d.ts

@@ -1,5 +0,9 @@

import { d as ActionAdapter, a as ActionCallbacksConfig } from '../ActionCallbacks-BOW0QdMv.js';
import { d as ActionAdapter, a as ActionCallbacksConfig, S as SecurityLevel } from '../security-D_VpEC5l.js';
declare function setupTwitterObserver(config: ActionAdapter, callbacks?: Partial<ActionCallbacksConfig>): void;
type ObserverSecurityLevel = SecurityLevel;
interface ObserverOptions {
securityLevel: ObserverSecurityLevel;
}
declare function setupTwitterObserver(config: ActionAdapter, callbacks?: Partial<ActionCallbacksConfig>, options?: Partial<ObserverOptions>): void;
export { setupTwitterObserver };
export { type ObserverOptions, setupTwitterObserver };
import {
Action,
ActionContainer
} from "../chunk-Y54H7POE.js";
ActionContainer,
ActionsRegistry,
checkSecurity,
getExtendedActionState
} from "../chunk-MFGSZTZJ.js";

@@ -13,2 +16,30 @@ // src/ext/twitter.tsx

// src/utils/interstitial-url.ts
var solanaActionPrefix = /^(solana-action:|solana:)/;
function isInterstitial(url) {
try {
const urlObj = new URL(url);
const actionUrl = urlObj.searchParams.get("action");
if (!actionUrl) {
return { isInterstitial: false };
}
const urlDecodedActionUrl = decodeURIComponent(actionUrl);
if (!solanaActionPrefix.test(urlDecodedActionUrl)) {
return { isInterstitial: false };
}
const decodedActionUrl = urlDecodedActionUrl.replace(
solanaActionPrefix,
""
);
const decodedActionUrlObj = new URL(decodedActionUrl);
return {
isInterstitial: true,
decodedActionUrl: decodedActionUrlObj.toString()
};
} catch (e) {
console.error(`Failed to check if URL is interstitial: ${url}`, e);
return { isInterstitial: false };
}
}
// src/utils/url-mapper.ts

@@ -67,19 +98,34 @@ var ActionsURLMapper = class {

import { jsx } from "react/jsx-runtime";
function setupTwitterObserver(config, callbacks = {}) {
var DEFAULT_OPTIONS = {
securityLevel: "only-trusted"
};
function setupTwitterObserver(config, callbacks = {}, options = DEFAULT_OPTIONS) {
const mergedOptions = { ...DEFAULT_OPTIONS, ...options };
const twitterReactRoot = document.getElementById("react-root");
const observer = new MutationObserver((mutations) => {
for (let i = 0; i < mutations.length; i++) {
const mutation = mutations[i];
for (let j = 0; j < mutation.addedNodes.length; j++) {
const node = mutation.addedNodes[j];
if (node.nodeType !== Node.ELEMENT_NODE) {
return;
const refreshRegistry = async () => {
await ActionsRegistry.getInstance().init();
setTimeout(refreshRegistry, 1e3 * 60 * 10);
};
refreshRegistry().then(() => {
const observer = new MutationObserver((mutations) => {
for (let i = 0; i < mutations.length; i++) {
const mutation = mutations[i];
for (let j = 0; j < mutation.addedNodes.length; j++) {
const node = mutation.addedNodes[j];
if (node.nodeType !== Node.ELEMENT_NODE) {
return;
}
handleNewNode(
node,
config,
callbacks,
mergedOptions
).catch(noop);
}
handleNewNode(node, config, callbacks).catch(noop);
}
}
});
observer.observe(twitterReactRoot, { childList: true, subtree: true });
});
observer.observe(twitterReactRoot, { childList: true, subtree: true });
}
async function handleNewNode(node, config, callbacks) {
async function handleNewNode(node, config, callbacks, options) {
const element = node;

@@ -100,9 +146,15 @@ if (!element || element.localName !== "div") {

const actionUrl = await resolveTwitterShortenedUrl(shortenedUrl);
const actionsJson = await fetch(actionUrl.origin + "/actions.json").then(
(res) => res.json()
);
const actionsUrlMapper = new ActionsURLMapper(actionsJson);
const actionApiUrl = actionsUrlMapper.mapUrl(actionUrl);
console.log("found action api url", actionApiUrl);
if (!actionApiUrl) {
const interstitialData = isInterstitial(actionUrl);
let actionApiUrl;
if (interstitialData.isInterstitial) {
actionApiUrl = interstitialData.decodedActionUrl;
} else {
const actionsJson = await fetch(actionUrl.origin + "/actions.json").then(
(res) => res.json()
);
const actionsUrlMapper = new ActionsURLMapper(actionsJson);
actionApiUrl = actionsUrlMapper.mapUrl(actionUrl);
}
const state = actionApiUrl ? getExtendedActionState(actionApiUrl) : null;
if (!actionApiUrl || !state || !checkSecurity(state, options.securityLevel)) {
return;

@@ -115,9 +167,22 @@ }

rootElement.parentElement?.replaceChildren(
createAction(actionUrl.toString(), action, callbacks)
createAction({
originalUrl: actionUrl,
action,
callbacks,
options,
isInterstitial: interstitialData.isInterstitial
})
);
}
function createAction(originalUrl, action, callbacks) {
function createAction({
originalUrl,
action,
callbacks,
options,
isInterstitial: isInterstitial2
}) {
const container = document.createElement("div");
container.className = "dialect-action-root-container";
const actionRoot = createRoot(container);
const websiteText = isInterstitial2 ? new URL(action.url).hostname : originalUrl.hostname;
actionRoot.render(

@@ -128,4 +193,6 @@ /* @__PURE__ */ jsx(

action,
websiteUrl: originalUrl,
callbacks
websiteUrl: originalUrl.toString(),
websiteText,
callbacks,
securityLevel: options.securityLevel
}

@@ -132,0 +199,0 @@ )

@@ -1,11 +0,33 @@

import { A as Action, a as ActionCallbacksConfig } from './ActionCallbacks-BOW0QdMv.js';
export { d as ActionAdapter, b as ActionComponent, e as ActionConfig, c as ActionContext, f as ActionError, g as ActionsSpecErrorResponse, h as ActionsSpecGetResponse, i as ActionsSpecPostRequestBody, j as ActionsSpecPostResponse, I as IncomingActionConfig, L as LinkedAction, P as Parameter, S as SolanaPaySpecGetResponse, k as SolanaPaySpecPostRequestBody, l as SolanaPaySpecPostResponse } from './ActionCallbacks-BOW0QdMv.js';
import { A as Action, a as ActionCallbacksConfig, S as SecurityLevel } from './security-D_VpEC5l.js';
export { d as ActionAdapter, b as ActionComponent, e as ActionConfig, c as ActionContext, f as ActionError, g as ActionsSpecErrorResponse, h as ActionsSpecGetResponse, i as ActionsSpecPostRequestBody, j as ActionsSpecPostResponse, I as IncomingActionConfig, L as LinkedAction, P as Parameter, k as SolanaPaySpecGetResponse, l as SolanaPaySpecPostRequestBody, m as SolanaPaySpecPostResponse } from './security-D_VpEC5l.js';
import * as react_jsx_runtime from 'react/jsx-runtime';
import { ReactNode } from 'react';
declare const ActionContainer: ({ action, websiteUrl, callbacks, }: {
declare class ActionsRegistry {
private static instance;
private actionsByHost;
private constructor();
static getInstance(config?: ActionsRegistryConfig): ActionsRegistry;
init(): Promise<void>;
lookup(actionUrl: string | URL): RegisteredAction | null;
}
interface ActionsRegistryConfig {
actions: RegisteredAction[];
}
interface RegisteredAction {
host: string;
state: 'trusted' | 'malicious';
}
type ExtendedActionState = RegisteredAction['state'] | 'unknown';
declare const getExtendedActionState: (actionOrUrl: Action | string) => ExtendedActionState;
declare const ActionContainer: ({ action, websiteUrl, websiteText, callbacks, securityLevel, }: {
action: Action;
websiteUrl?: string;
websiteText?: string;
callbacks?: Partial<ActionCallbacksConfig>;
securityLevel?: SecurityLevel;
}) => react_jsx_runtime.JSX.Element;
type ActionType = ExtendedActionState;
interface LayoutProps {

@@ -17,2 +39,4 @@ image?: string;

websiteText?: string | null;
disclaimer?: ReactNode;
type: ActionType;
title: string;

@@ -36,4 +60,4 @@ description: string;

}
declare const ActionLayout: ({ title, description, image, websiteUrl, websiteText, buttons, inputs, error, success, }: LayoutProps) => react_jsx_runtime.JSX.Element;
declare const ActionLayout: ({ title, description, image, websiteUrl, websiteText, type, disclaimer, buttons, inputs, error, success, }: LayoutProps) => react_jsx_runtime.JSX.Element;
export { Action, ActionCallbacksConfig, ActionContainer, ActionLayout, type ButtonProps, type InputProps };
export { Action, ActionCallbacksConfig, ActionContainer, ActionLayout, ActionsRegistry, type ActionsRegistryConfig, type ButtonProps, type ExtendedActionState, type InputProps, type RegisteredAction, getExtendedActionState };

@@ -6,4 +6,6 @@ import {

ActionContainer,
ActionLayout
} from "./chunk-Y54H7POE.js";
ActionLayout,
ActionsRegistry,
getExtendedActionState
} from "./chunk-MFGSZTZJ.js";
export {

@@ -14,4 +16,6 @@ Action,

ActionContainer,
ActionLayout
ActionLayout,
ActionsRegistry,
getExtendedActionState
};
//# sourceMappingURL=index.js.map
{
"name": "@dialectlabs/actions-ui",
"version": "0.1.0-beta.8",
"version": "0.1.0-beta.9",
"license": "Apache-2.0",

@@ -56,3 +56,6 @@ "private": false,

"react-dom": ">=18"
},
"dependencies": {
"clsx": "^2.1.1"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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