diff --git a/rpc/src/core/webview.ts b/rpc/src/core/webview.ts index 3ed04af..17836e1 100644 --- a/rpc/src/core/webview.ts +++ b/rpc/src/core/webview.ts @@ -164,6 +164,8 @@ export class RPCInstanceWebview extends RPCInstanceBase { }, body: stringify(data), } + // FiveM injects GetParentResourceName into NUI pages. Without it (page + // opened in a regular browser) the fetch fails and the call rejects. const resourceName = window?.GetParentResourceName?.() ?? 'nui-frame-app' return fetch( `https://${resourceName}/${RPCEvents.LISTENER_WEB}`, diff --git a/rpc/src/utils/funcs.ts b/rpc/src/utils/funcs.ts index 977057d..f67646d 100644 --- a/rpc/src/utils/funcs.ts +++ b/rpc/src/utils/funcs.ts @@ -64,7 +64,14 @@ export function stringifyWeb(data: RPCStateWeb): RPCStateWebRaw { return JSON.stringify(data) as RPCStateWebRaw } -/** **Internal** */ +/** + * **Internal** + * + * UUID v4 shaped call id. Not `crypto.randomUUID`: the FiveM client runtime + * has no `crypto` global, and one generator serves all environments. Only + * pairs a response with its call, so it need not be unguessable: the server + * binds each call to its target player (`Pending` peer check). + */ export function generateUUID(): string { let uuid = '' let random = 0