Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@dialectlabs/blinks-core

Package Overview
Dependencies
Maintainers
0
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dialectlabs/blinks-core - npm Package Compare versions

Comparing version 0.15.0 to 0.16.0

14

dist/index.d.ts

@@ -306,2 +306,6 @@ import { ActionGetResponse, SignMessageData as SignMessageData$1, NextActionLink, PostNextActionLink, MessageNextActionPostRequest, NextActionPostRequest, NextAction, LinkedActionType, TypedActionParameter, ActionPostRequest, ActionPostResponse, GeneralParameterType, SelectableParameterType } from '@solana/actions-spec';

onActionMount: (action: Action$1, originalUrl: string, type: 'trusted' | 'malicious' | 'unknown') => void;
onActionCancel: (action: Action$1, trigger: AbstractActionComponent, reason: string) => void;
onActionChain: (previousAction: Action$1, chainedAction: Action$1, chainTrigger: AbstractActionComponent, chainType: LinkedActionType, signature?: string) => void;
onActionComplete: (action: Action$1, trigger: AbstractActionComponent, signature?: string) => void;
onActionError: (action: Action$1, trigger: AbstractActionComponent, reason: string, signature?: string) => void;
}

@@ -315,6 +319,7 @@

private interstitialsByHost;
private initPromise;
private intervalId;
private constructor();
static getInstance(config?: ActionsRegistryConfig): ActionsRegistry;
init(): Promise<void>;
stopRefresh(): void;
refresh(): Promise<void>;

@@ -368,2 +373,4 @@ lookup(url: string | URL, type?: LookupType): RegisteredEntity | null;

declare const SOLANA_ACTION_PREFIX: RegExp;
type IsInterstitialResult = {

@@ -485,2 +492,3 @@ isInterstitial: true;

isLoading: boolean;
refresh: () => () => void;
};

@@ -509,2 +517,3 @@

};
declare function fetchBlinkList(): Promise<BlinkList>;

@@ -531,3 +540,4 @@ interface UseMetadataArgs {

};
declare function fetchMetadata(url: string, wallet?: string): Promise<BlinkMetadata>;
export { AbstractActionComponent, Action$1 as Action, type ActionAdapter, type ActionAdapterMetadata, type ActionCallbacksConfig, ActionConfig, type ActionContext, type ActionSupportStrategy, type ActionSupportability, type ActionsJsonConfig, ActionsRegistry, type ActionsRegistryConfig, ActionsURLMapper, BASELINE_ACTION_BLOCKCHAIN_IDS, BASELINE_ACTION_VERSION, BLINK_CLIENT_KEY_HEADER, type BaseBlinkLayoutProps, type BlinkCaption, BlinkContainer, type BlinkContainerProps, type BlinkList, type BlinkListEntry, type BlinkMetadata, type BlinkSecurityState, BlockchainIds, ButtonActionComponent, DEFAULT_SUPPORTED_BLOCKCHAIN_IDS, type DialectExperimentalFeatures, type Disclaimer, DisclaimerType, type ExecutionState, type ExecutionStatus, ExecutionType, type ExtendedActionGetResponse, type ExtraExecutionData, FormActionComponent, type IncomingActionConfig, type IsInterstitialResult, type LookupType, MAX_SUPPORTED_ACTION_VERSION, type MetadataRow, MultiValueActionComponent, type RegisteredEntity, type SecurityActionState, type SecurityLevel, type SignMessageData, SignMessageVerificationErrorType, type SignMessageVerificationOptions, SingleValueActionComponent, type SolanaPaySpecGetResponse, type SolanaPaySpecPostRequestBody, type SolanaPaySpecPostResponse, checkSecurity, createSignMessageText, defaultActionSupportStrategy, getExtendedActionState, getExtendedInterstitialState, getExtendedWebsiteState, isBlockchainSupported, isInterstitial, isParameterSelectable, isPatternAllowed, isVersionSupported, mergeActionStates, parseSignMessageText, proxify, proxifyImage, setClientKey, setProxyUrl, unfurlUrlToActionApiUrl, useAction, useActionsRegistryInterval, useBlinkList, useMetadata, verifySignMessageData };
export { AbstractActionComponent, Action$1 as Action, type ActionAdapter, type ActionAdapterMetadata, type ActionCallbacksConfig, ActionConfig, type ActionContext, type ActionSupportStrategy, type ActionSupportability, type ActionsJsonConfig, ActionsRegistry, type ActionsRegistryConfig, ActionsURLMapper, BASELINE_ACTION_BLOCKCHAIN_IDS, BASELINE_ACTION_VERSION, BLINK_CLIENT_KEY_HEADER, type BaseBlinkLayoutProps, type BlinkCaption, BlinkContainer, type BlinkContainerProps, type BlinkList, type BlinkListEntry, type BlinkMetadata, type BlinkSecurityState, BlockchainIds, ButtonActionComponent, DEFAULT_SUPPORTED_BLOCKCHAIN_IDS, type DialectExperimentalFeatures, type Disclaimer, DisclaimerType, type ExecutionState, type ExecutionStatus, ExecutionType, type ExtendedActionGetResponse, type ExtraExecutionData, FormActionComponent, type IncomingActionConfig, type IsInterstitialResult, type LookupType, MAX_SUPPORTED_ACTION_VERSION, type MetadataRow, MultiValueActionComponent, type RegisteredEntity, SOLANA_ACTION_PREFIX, type SecurityActionState, type SecurityLevel, type SignMessageData, SignMessageVerificationErrorType, type SignMessageVerificationOptions, SingleValueActionComponent, type SolanaPaySpecGetResponse, type SolanaPaySpecPostRequestBody, type SolanaPaySpecPostResponse, checkSecurity, createSignMessageText, defaultActionSupportStrategy, fetchBlinkList, fetchMetadata, getExtendedActionState, getExtendedInterstitialState, getExtendedWebsiteState, isBlockchainSupported, isInterstitial, isParameterSelectable, isPatternAllowed, isVersionSupported, mergeActionStates, parseSignMessageText, proxify, proxifyImage, setClientKey, setProxyUrl, unfurlUrlToActionApiUrl, useAction, useActionsRegistryInterval, useBlinkList, useMetadata, verifySignMessageData };

122

dist/index.js

@@ -44,2 +44,3 @@ // src/utils/caip-2.ts

var SOLANA_ACTION_PREFIX = /^(solana-action:|solana:)/;
var EMPTY_OBJECT = Object.freeze({});

@@ -223,3 +224,3 @@ // src/utils/interstitial-url.ts

name: "@dialectlabs/blinks-core",
version: "0.15.0",
version: "0.16.0",
license: "Apache-2.0",

@@ -1057,3 +1058,3 @@ private: false,

interstitialsByHost;
initPromise = null;
intervalId = null;
constructor(config) {

@@ -1080,11 +1081,19 @@ this.actionsByHost = config ? Object.fromEntries(

async init() {
if (this.initPromise !== null) {
if (this.intervalId !== null) {
return;
}
await this.refresh();
setInterval(() => this.refresh(), DEFAULT_REFRESH_INTERVAL);
this.intervalId = setInterval(
() => this.refresh(),
DEFAULT_REFRESH_INTERVAL
);
}
stopRefresh() {
if (this.intervalId !== null) {
clearInterval(this.intervalId);
this.intervalId = null;
}
}
async refresh() {
this.initPromise = fetchActionsRegistryConfig();
const config = await this.initPromise;
const config = await fetchActionsRegistryConfig();
this.actionsByHost = Object.fromEntries(

@@ -1319,3 +1328,3 @@ config.actions.map((action) => [action.host, action])

websiteText,
callbacks,
callbacks = EMPTY_OBJECT,
securityLevel = DEFAULT_SECURITY_LEVEL,

@@ -1367,8 +1376,8 @@ Layout,

useEffect(() => {
callbacks?.onActionMount?.(
action,
websiteUrl ?? action.url,
callbacks.onActionMount?.(
initialAction,
websiteUrl ?? initialAction.url,
actionState.action
);
}, [action.id]);
}, []);
useEffect(() => {

@@ -1444,2 +1453,3 @@ const liveDataConfig = action.liveData_experimental;

dispatch({ type: "BLOCK" /* BLOCK */ });
callbacks.onActionCancel?.(action, component, "security-state-changed");
return;

@@ -1458,2 +1468,3 @@ }

dispatch({ type: "RESET" /* RESET */ });
callbacks?.onActionCancel?.(action, component, "wallet-not-connected");
return;

@@ -1467,2 +1478,3 @@ }

});
callbacks.onActionError?.(action, component, "post-request-error");
return;

@@ -1476,2 +1488,3 @@ }

});
callbacks.onActionComplete?.(action, component, signature);
return;

@@ -1484,2 +1497,7 @@ }

});
callbacks.onActionError?.(
action,
component,
"message-signature-missing"
);
return;

@@ -1502,2 +1520,3 @@ }

});
callbacks.onActionComplete?.(action, component, signature);
return;

@@ -1507,2 +1526,9 @@ }

dispatch({ type: "RESET" /* RESET */ });
callbacks.onActionChain?.(
action,
nextAction,
component,
response.type,
signature
);
};

@@ -1516,5 +1542,23 @@ if (response.type === "transaction" || !response.type) {

dispatch({ type: "RESET" /* RESET */ });
callbacks.onActionCancel?.(
action,
component,
"transaction-sign-cancel"
);
return;
}
await adapter.confirmTransaction(signResult.signature, context);
const confirmationResult = await adapter.confirmTransaction(signResult.signature, context).then(() => ({ success: true })).catch((e) => ({ success: false, message: e.message }));
if (!confirmationResult.success) {
dispatch({
type: "SOFT_RESET" /* SOFT_RESET */,
errorMessage: confirmationResult.message ?? "Unknown error, please try again"
});
callbacks.onActionError?.(
action,
component,
"transaction-confirmation-failed",
signResult.signature
);
return;
}
await chain(signResult.signature);

@@ -1527,2 +1571,3 @@ return;

dispatch({ type: "RESET" /* RESET */ });
callbacks.onActionCancel?.(action, component, "message-sign-cancel");
return;

@@ -1555,2 +1600,3 @@ }

});
callbacks.onActionError?.(action, component, "unknown-error");
}

@@ -1604,3 +1650,3 @@ };

// src/hooks/useAction.ts
import { useEffect as useEffect3, useState as useState3 } from "react";
import { useCallback, useEffect as useEffect3, useState as useState3 } from "react";

@@ -1612,5 +1658,9 @@ // src/hooks/useActionRegistryInterval.ts

useEffect2(() => {
ActionsRegistry.getInstance().init().then(() => {
const registry = ActionsRegistry.getInstance();
registry.init().then(() => {
setRegistryLoaded(true);
});
return () => {
registry.stopRefresh();
};
}, [isRegistryLoaded]);

@@ -1652,18 +1702,20 @@ return { isRegistryLoaded };

const [hasFetched, setHasFetched] = useState3(false);
useEffect3(() => {
setIsLoading(true);
if (!isRegistryLoaded || !actionApiUrl) {
return;
const fetchAction = useCallback(() => {
if (!actionApiUrl) {
return () => {
};
}
let ignore = false;
setIsLoading(true);
setHasFetched(false);
Action.fetch(actionApiUrl, supportStrategy).then((action2) => {
if (ignore) {
return;
if (!ignore) {
setAction(action2);
setHasFetched(true);
}
setAction(action2);
setHasFetched(true);
}).catch((e) => {
console.error("[@dialectlabs/blinks-core] Failed to fetch action", e);
setAction(null);
if (!ignore) {
console.error("[@dialectlabs/blinks-core] Failed to fetch action", e);
setAction(null);
}
}).finally(() => {

@@ -1677,2 +1729,11 @@ if (!ignore) {

};
}, [actionApiUrl, supportStrategy]);
useEffect3(() => {
if (!isRegistryLoaded) {
return;
}
const cleanup = fetchAction();
return () => {
cleanup();
};
}, [actionApiUrl, isRegistryLoaded]);

@@ -1692,11 +1753,11 @@ useEffect3(() => {

}, [supportStrategy, hasFetched]);
return { action, isLoading };
return { action, isLoading, refresh: fetchAction };
}
// src/hooks/useBlinkList.ts
import { useCallback, useEffect as useEffect4, useState as useState4 } from "react";
import { useCallback as useCallback2, useEffect as useEffect4, useState as useState4 } from "react";
var useBlinkList = () => {
const [loading, setLoading] = useState4(false);
const [data, setData] = useState4();
const refetch = useCallback(() => {
const refetch = useCallback2(() => {
let ignore = false;

@@ -1759,7 +1820,7 @@ setLoading(true);

// src/hooks/useMetadata.ts
import { useCallback as useCallback2, useEffect as useEffect5, useState as useState5 } from "react";
import { useCallback as useCallback3, useEffect as useEffect5, useState as useState5 } from "react";
var useMetadata = ({ url, wallet }) => {
const [loading, setLoading] = useState5(false);
const [data, setData] = useState5();
const refetch = useCallback2(() => {
const refetch = useCallback3(() => {
let ignore = false;

@@ -1842,2 +1903,3 @@ setLoading(true);

MultiValueActionComponent,
SOLANA_ACTION_PREFIX,
SignMessageVerificationErrorType,

@@ -1848,2 +1910,4 @@ SingleValueActionComponent,

defaultActionSupportStrategy,
fetchBlinkList,
fetchMetadata,
getExtendedActionState,

@@ -1850,0 +1914,0 @@ getExtendedInterstitialState,

{
"name": "@dialectlabs/blinks-core",
"version": "0.15.0",
"version": "0.16.0",
"license": "Apache-2.0",

@@ -5,0 +5,0 @@ "private": false,

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