Socket
Socket
Sign inDemoInstall

@cartridge/controller

Package Overview
Dependencies
Maintainers
2
Versions
104
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cartridge/controller - npm Package Compare versions

Comparing version 0.3.20 to 0.3.21

12

dist/index.d.ts
/// <reference types="node" />
export * from "./types";
import { AccountInterface, constants, RpcProvider } from "starknet";
import { AsyncMethodReturns } from "@cartridge/penpal";
import { Session, Keychain, Policy } from "./types";
import { Session, Keychain, Policy, ControllerOptions } from "./types";
export declare const providers: {

@@ -18,9 +19,6 @@ [key: string]: RpcProvider;

private modal?;
constructor(policies?: Policy[], options?: {
url?: string;
origin?: string;
starterPackId?: string;
chainId?: constants.StarknetChainId;
});
constructor(policies?: Policy[], options?: ControllerOptions);
get account(): AccountInterface | undefined;
private setCustomTheme;
private encodeColor;
ready(): Promise<boolean>;

@@ -27,0 +25,0 @@ probe(): Promise<true | null | undefined>;

@@ -1,5 +0,8 @@

import { constants, RpcProvider } from "starknet";
export * from "./types";
import { addAddressPadding, constants, RpcProvider, } from "starknet";
import { connectToChild, } from "@cartridge/penpal";
import DeviceAccount from "./device";
import { ResponseCodes, } from "./types";
import { ResponseCodes,
// CustomIcon,
} from "./types";
import { createModal } from "./modal";

@@ -21,3 +24,8 @@ export const providers = {

if (policies) {
this.policies = policies;
this.policies = policies.map((policy) => {
return {
...policy,
target: addAddressPadding(policy.target),
};
});
}

@@ -27,8 +35,11 @@ if (options?.chainId) {

}
// if (options?.starterPackId) {
// this.starterPackId = options.starterPackId;
// }
if (options?.url) {
this.url = options.url;
}
// if (options?.icon) {
// this.setCustomIcon(options.icon);
// }
if (options?.theme) {
this.setCustomTheme(options.theme);
}
if (typeof document === "undefined") {

@@ -62,2 +73,26 @@ return;

}
// private setCustomIcon(icon: CustomIcon) {
// const url = new URL(this.url);
// url.searchParams.set("icon", encodeURIComponent(JSON.stringify(icon)));
// this.url = url.toString();
// }
setCustomTheme(theme) {
const url = new URL(this.url);
const primary = this.encodeColor(theme.colors?.primary);
if (primary) {
url.searchParams.set("primary", primary);
}
const secondary = this.encodeColor(theme.colors?.secondary);
if (secondary) {
url.searchParams.set("secondary", secondary);
}
this.url = url.toString();
}
encodeColor(color) {
if (!color)
return;
return typeof color === "string"
? color
: encodeURIComponent(JSON.stringify(color));
}
ready() {

@@ -64,0 +99,0 @@ return (this.connection?.promise

@@ -18,2 +18,7 @@ /// <reference types="node" />

maxFee: BigNumberish;
expiresAt: bigint;
credentials: {
authorization: string[];
privateKey: string;
};
};

@@ -94,1 +99,20 @@ export type Policy = {

}
export type ControllerOptions = {
url?: string;
origin?: string;
starterPackId?: string;
chainId?: constants.StarknetChainId;
theme?: CustomTheme;
};
export type CustomTheme = {
colors?: CustomColors;
};
export type CustomColors = {
primary?: CustomColor;
secondary?: CustomColor;
};
export type CustomColor = ThemeValue<string>;
export type ThemeValue<T> = T | {
dark: T;
light: T;
};
{
"name": "@cartridge/controller",
"version": "0.3.20",
"version": "0.3.21",
"description": "Cartridge Controller",

@@ -22,3 +22,3 @@ "module": "dist/index.js",

"typescript": "^5.4.5",
"@cartridge/tsconfig": "^0.0.1"
"@cartridge/tsconfig": "^0.3.21"
},

@@ -25,0 +25,0 @@ "scripts": {

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