Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions types/frida-gum/frida-gum-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ Process.mainModule;
// $ExpectType string | null
Process.mainModule.version;

// $ExpectType MemoryRange
Process.getFunctionRange(Process.mainModule.base);

// $ExpectType MemoryRange | null
Process.findFunctionRange(Process.mainModule.base);

Expand Down Expand Up @@ -451,6 +454,12 @@ Stalker.invalidate(Process.getCurrentThreadId(), basicBlockStartAddress);
// $ExpectType boolean
Cloak.hasCurrentThread();

// $ExpectType ThreadDetails
Process.getThreadById(Process.getCurrentThreadId());

// $ExpectType ThreadDetails | null
Process.findThreadById(Process.getCurrentThreadId());

Process.enumerateThreads().forEach(t => {
t.setHardwareBreakpoint(0, puts);
});
Expand Down
47 changes: 35 additions & 12 deletions types/frida-gum/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,23 @@ declare namespace Process {
*/
function getCurrentThreadId(): ThreadId;

/**
* Looks up a single thread by its ID, throwing an exception if it cannot be
* found. Unlike `enumerateThreads()`, cloaked threads are not hidden: an
* explicit lookup by ID always returns the thread if it exists.
*
* @param id ID of the thread to find.
*/
function getThreadById(id: ThreadId): ThreadDetails;

/**
* Like `getThreadById()`, but returns null instead of throwing if the
* thread cannot be found.
*
* @param id ID of the thread to find.
*/
function findThreadById(id: ThreadId): ThreadDetails | null;

/**
* Enumerates all threads.
*/
Expand Down Expand Up @@ -394,26 +411,26 @@ declare namespace Process {
*/
function runOnThread<T>(id: ThreadId, callback: () => T): Promise<T>;

/**
* Looks up a module by address. Returns null if not found.
*/
function findModuleByAddress(address: NativePointerValue): Module | null;

/**
* Looks up a module by address. Throws an exception if not found.
*/
function getModuleByAddress(address: NativePointerValue): Module;

/**
* Looks up a module by name. Returns null if not found.
* Looks up a module by address. Returns null if not found.
*/
function findModuleByName(name: string): Module | null;
function findModuleByAddress(address: NativePointerValue): Module | null;

/**
* Looks up a module by name. Throws an exception if not found.
*/
function getModuleByName(name: string): Module;

/**
* Looks up a module by name. Returns null if not found.
*/
function findModuleByName(name: string): Module | null;

/**
* Enumerates modules loaded right now.
*/
Expand All @@ -429,14 +446,14 @@ declare namespace Process {
function attachModuleObserver(callbacks: ModuleObserverCallbacks): ModuleObserver;

/**
* Looks up a memory range by address. Returns null if not found.
* Looks up a memory range by address. Throws an exception if not found.
*/
function findRangeByAddress(address: NativePointerValue): RangeDetails | null;
function getRangeByAddress(address: NativePointerValue): RangeDetails;

/**
* Looks up a memory range by address. Throws an exception if not found.
* Looks up a memory range by address. Returns null if not found.
*/
function getRangeByAddress(address: NativePointerValue): RangeDetails;
function findRangeByAddress(address: NativePointerValue): RangeDetails | null;

/**
* Determines the code range of the function that `address` belongs to,
Expand All @@ -445,7 +462,13 @@ declare namespace Process {
* per fragment; this returns the one covering `address`. Where no unwind
* information is available — e.g. a leaf function, or a target lacking
* unwind tables altogether — the containing symbol's bounds are used as a
* best-effort fallback. Returns null if neither yields a range.
* best-effort fallback. Throws an exception if neither yields a range.
*/
function getFunctionRange(address: NativePointerValue): MemoryRange;

/**
* Like `getFunctionRange()`, but returns null instead of throwing if no
* range can be determined.
*/
function findFunctionRange(address: NativePointerValue): MemoryRange | null;

Expand Down
2 changes: 1 addition & 1 deletion types/frida-gum/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@types/frida-gum",
"version": "19.6.9999",
"version": "19.7.9999",
"nonNpm": true,
"nonNpmDescription": "frida-gum",
"projects": [
Expand Down
69 changes: 64 additions & 5 deletions types/invity-api/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,67 @@ export interface TradeCommon {
statusUrl?: string | null; // URL with ID assigned to the trade by the provider to check status; if null, do not show any status url
}

export type DomainEntity =
| "partner"
| "country"
| "subdivision"
| "token"
| "payment-method"
| "client-restriction"
| "network"
| "info-note"
| "experiment"
| "otc-link"
| "staff"
| "app"
| "service"
| "version";

export const ERROR_CODES: readonly [
"unavailable",
"invalid_address",
"invalid_amount",
"invalid_input",
"invalid_pair",
"invalid_response",
"no_response",
"trade_not_found",
"trade_expired",
"trade_failed",
"trade_refunded",
"unknown",
];
export type ErrorCode = (typeof ERROR_CODES)[number];

export const ERROR_ORIGINS: readonly ["internal", "external", "partner"];
export type ErrorOrigin = (typeof ERROR_ORIGINS)[number];

export type TradeErrorDetailsMap = {
[C in ErrorCode]: C extends "unavailable"
? { code: C; entity?: { type: DomainEntity; value: string }; reason?: string }
: C extends "invalid_address" ? { code: C; address?: { key: string; value?: string } }
: C extends "invalid_amount" ? { code: C; amount?: { key: string; value: string; min?: string; max?: string } }
: C extends "invalid_input" ? { code: C; inputs?: string[] }
: C extends "invalid_pair" ? { code: C; pair?: { send: string; receive: string } }
: C extends "invalid_response" ? { code: C; errors?: string[] }
: C extends "no_response" ? { code: C }
: C extends "trade_not_found" ? { code: C; id?: string }
: C extends "trade_expired" | "trade_failed" | "trade_refunded" ? { code: C; orderId?: string }
: { code: C }; // unknown
};
export interface TradeErrorDetailsBase {
origin: ErrorOrigin; // who trade error conceptually belongs to
externalCode?: string;
message?: string;
}
export type TradeErrorCodeSpecificData = TradeErrorDetailsMap[ErrorCode];
export type TradeErrorDetails = TradeErrorDetailsBase & TradeErrorCodeSpecificData;

export interface TradeError {
error: string; // formatted error message
errorDetails?: TradeErrorDetails;
}

// buy types

export type BuyTradeFinalStatus =
Expand Down Expand Up @@ -362,7 +423,7 @@ export type DexApprovalType =
| "ZERO" // resets approval
| "PRESET"; // PRESET takes value from approvalStringAmount

export interface ExchangeTrade extends TradeCommon {
export type ExchangeTrade = TradeCommon & Partial<TradeError> & {
send?: CryptoId | undefined; // bitcoin

sendStringAmount?: string | undefined; // "0.01"
Expand All @@ -383,7 +444,6 @@ export interface ExchangeTrade extends TradeCommon {
orderId?: string | undefined; // internal ID assigned to the trade by the exchange
quoteId?: string | undefined;
status?: ExchangeTradeStatus | undefined; // state of trade after confirmTrade
error?: string | undefined; // something went wrong after confirmTrade
receiveTxHash?: string | undefined; // hash of tx from exchange to user or DEX swap
cid?: string | undefined; // google clientID
offerReferenceId?: string | undefined; // coinswitch only
Expand Down Expand Up @@ -421,7 +481,7 @@ export interface ExchangeTrade extends TradeCommon {
// locally used fields
offerType?: "bestRate" | "favorite" | undefined;
tradeForm?: FormResponse;
}
};

export interface ExchangeTradeSigned extends ExchangeTrade {
/** SLIP24: Nonce for payment request signature */
Expand Down Expand Up @@ -460,14 +520,13 @@ export interface ConfirmExchangeTradeRequest {
returnUrl?: string; // URL where to return after the trade is done
}

export interface WatchExchangeTradeResponse {
export interface WatchExchangeTradeResponse extends Partial<TradeError> {
status?: ExchangeTradeStatus | undefined; // state of trade after confirmTrade
sendAddress?: string; // exchange address for send tx
partnerPaymentExtraId?: string; // Extra ID for payments to exchange for networks that require it (destinationTag)
receiveTxHash?: string | undefined;
rate?: number | undefined;
receiveStringAmount?: string | undefined; // "0.01"
error?: string | undefined; // something went wrong after confirmTrade
}

// utilityTypes
Expand Down
25 changes: 25 additions & 0 deletions types/invity-api/invity-api-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
CreateTradeSignatureRequestExchange,
CreateTradeSignatureRequestSell,
CryptoId,
DomainEntity,
ExchangeProviderInfo,
ExchangeTrade,
ExchangeTradeQuoteRequest,
Expand All @@ -18,6 +19,7 @@ import {
SellFiatTradeSigned,
SellListResponse,
SellProviderInfo,
WatchExchangeTradeResponse,
WatchSellTradeResponse,
} from "invity-api";

Expand Down Expand Up @@ -47,6 +49,17 @@ const et: ExchangeTrade = {
data: {},
},
status: "SIGN_DATA",
error: "Invalid currency: unknowncoin not found",
errorDetails: {
origin: "partner",
externalCode: "-32602",
message: "Invalid currency: unknowncoin not found",
code: "invalid_pair",
pair: {
send: "unknowncoin",
receive: "ethereum",
},
},
};

const ets: ExchangeTradeSigned = {
Expand All @@ -73,6 +86,16 @@ const wstr: WatchSellTradeResponse = {
cryptoStringAmount: "",
};

const wetrErr: WatchExchangeTradeResponse = {
error: "Invalid method",
errorDetails: {
origin: "partner",
externalCode: "-32601",
message: "Invalid method",
code: "unknown",
},
};

const providerInfo: BuyProviderInfo = {
companyName: "Invity",
brandName: "UAB Invity Finance",
Expand Down Expand Up @@ -287,3 +310,5 @@ const sellListResponse: SellListResponse = {
const buyPaymentMethod: BuyCryptoPaymentMethod = "blik";

const sellPaymentMethod: SellCryptoPaymentMethod = "pix";

const entity: DomainEntity = "partner";
7 changes: 7 additions & 0 deletions types/office-runtime/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,14 +362,21 @@ declare namespace OfficeRuntime {
}
/**
* Provides information about what Requirement Sets are supported in current environment.
*
* @deprecated This API returns inaccurate values when used on desktop applications. Use `Office.context.requirements.isSetSupported` instead.
*/
const apiInformation: ApiInformation;
/**
* Interface that contains methods for checking API requirement-set support.
*
* @deprecated This API returns inaccurate values when used on desktop applications. Use `Office.context.requirements.isSetSupported` instead.
*/
interface ApiInformation {
/**
* Check if the specified requirement set is supported by the Office application.
*
* @deprecated This API returns inaccurate values when used on desktop applications. Use `Office.context.requirements.isSetSupported` instead.
*
* @param name - Set name; e.g., "MatrixBindings".
* @param minVersion - The minimum required version; e.g., "1.4".
*/
Expand Down
Loading