@flow-industries/id 0.22.0 → 0.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -0
- package/contracts/v1/openapi.json +818 -0
- package/contracts/v1/reports.json +188 -0
- package/contracts/v1/sdk-exports.json +1165 -0
- package/dist/sdk/client/dialog-host.js +11 -6
- package/dist/sdk/client/flow-widget.js +3 -3
- package/dist/sdk/client/iframe-host.d.ts +2 -1
- package/dist/sdk/client/iframe-host.js +11 -1
- package/dist/sdk/client/index.d.ts +2 -0
- package/dist/sdk/client/index.js +1 -0
- package/dist/sdk/client/open-profile.js +10 -7
- package/dist/sdk/client/profile-button.js +16 -9
- package/dist/sdk/client/reports.d.ts +9 -0
- package/dist/sdk/client/reports.js +30 -0
- package/dist/sdk/contracts/http.d.ts +155 -0
- package/dist/sdk/contracts/http.js +91 -0
- package/dist/sdk/contracts/reports.d.ts +130 -0
- package/dist/sdk/contracts/reports.js +67 -0
- package/dist/sdk/dialog/remote/Messenger.d.ts +3 -0
- package/dist/sdk/dialog/remote/Messenger.js +9 -3
- package/dist/sdk/types/index.d.ts +1 -0
- package/dist/sdk/types/reports.d.ts +7 -0
- package/dist/sdk/types/reports.js +0 -0
- package/package.json +16 -8
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** Game server → auth: a reportable XP event. */
|
|
3
|
+
export const xpEventSchema = z.object({
|
|
4
|
+
sub: z.string(),
|
|
5
|
+
source: z.string(),
|
|
6
|
+
durationSeconds: z.number().finite().optional(),
|
|
7
|
+
idempotencyKey: z.string().optional(),
|
|
8
|
+
});
|
|
9
|
+
/** Talk and the game report a full snapshot of every active room they hold. */
|
|
10
|
+
export const presenceReportSchema = z.object({
|
|
11
|
+
channel: z.enum(["game", "voice", "text"]),
|
|
12
|
+
rooms: z.array(z.object({
|
|
13
|
+
roomId: z.string(),
|
|
14
|
+
occupants: z.array(z.looseObject({ sub: z.string() })),
|
|
15
|
+
})),
|
|
16
|
+
});
|
|
17
|
+
const POSITION_VALUE_LIMIT = 1_000_000;
|
|
18
|
+
const WORLD_ID_MAX_LENGTH = 64;
|
|
19
|
+
const positionValue = z
|
|
20
|
+
.number()
|
|
21
|
+
.min(-POSITION_VALUE_LIMIT)
|
|
22
|
+
.max(POSITION_VALUE_LIMIT);
|
|
23
|
+
/** The game server checkpoints each tracked player's last grounded footing. */
|
|
24
|
+
export const positionReportSchema = z.object({
|
|
25
|
+
positions: z.array(z.object({
|
|
26
|
+
roomId: z.string(),
|
|
27
|
+
sub: z.string(),
|
|
28
|
+
x: positionValue,
|
|
29
|
+
y: positionValue,
|
|
30
|
+
z: positionValue,
|
|
31
|
+
yaw: positionValue,
|
|
32
|
+
worldId: z.string().max(WORLD_ID_MAX_LENGTH),
|
|
33
|
+
})),
|
|
34
|
+
});
|
|
35
|
+
export const actionStartSchema = z.object({
|
|
36
|
+
sub: z.string(),
|
|
37
|
+
sessionId: z.string(),
|
|
38
|
+
source: z.string(),
|
|
39
|
+
showTimer: z.boolean().optional(),
|
|
40
|
+
});
|
|
41
|
+
export const actionFinishSchema = z.object({
|
|
42
|
+
sessionId: z.string(),
|
|
43
|
+
});
|
|
44
|
+
export const actionEventSchema = z.object({
|
|
45
|
+
sessionId: z.string(),
|
|
46
|
+
kind: z.enum(["pause", "resume", "focus_lost", "focus_gained"]),
|
|
47
|
+
});
|
|
48
|
+
export const stateTimeSchema = z.object({
|
|
49
|
+
sub: z.string(),
|
|
50
|
+
day: z.string(),
|
|
51
|
+
states: z.record(z.string(), z.number()),
|
|
52
|
+
});
|
|
53
|
+
export const xpDevSchema = z.object({
|
|
54
|
+
sub: z.string(),
|
|
55
|
+
op: z.enum(["add", "set_total", "set_level"]),
|
|
56
|
+
value: z.number().finite(),
|
|
57
|
+
});
|
|
58
|
+
export const reportSchemas = {
|
|
59
|
+
xpEvent: xpEventSchema,
|
|
60
|
+
presenceReport: presenceReportSchema,
|
|
61
|
+
positionReport: positionReportSchema,
|
|
62
|
+
actionStart: actionStartSchema,
|
|
63
|
+
actionEvent: actionEventSchema,
|
|
64
|
+
actionFinish: actionFinishSchema,
|
|
65
|
+
stateTime: stateTimeSchema,
|
|
66
|
+
xpDev: xpDevSchema,
|
|
67
|
+
};
|
|
@@ -12,6 +12,9 @@ export declare function from(messenger: Messenger): Messenger;
|
|
|
12
12
|
* isolation that prevents arbitrary pages from injecting messages.
|
|
13
13
|
*/
|
|
14
14
|
export declare function fromWindow(w: Window, options?: FromWindowOptions): Messenger;
|
|
15
|
+
export declare class BridgeDestroyedError extends Error {
|
|
16
|
+
constructor();
|
|
17
|
+
}
|
|
15
18
|
/**
|
|
16
19
|
* Combines two Messengers into a bidirectional bridge: `from` is read-side
|
|
17
20
|
* (inbound messages), `to` is write-side (outbound). Adds a "ready"
|
|
@@ -87,6 +87,12 @@ export function fromWindow(w, options = {}) {
|
|
|
87
87
|
},
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
|
+
export class BridgeDestroyedError extends Error {
|
|
91
|
+
constructor() {
|
|
92
|
+
super("Message bridge destroyed before the peer was ready");
|
|
93
|
+
this.name = "BridgeDestroyedError";
|
|
94
|
+
}
|
|
95
|
+
}
|
|
90
96
|
/**
|
|
91
97
|
* Combines two Messengers into a bidirectional bridge: `from` is read-side
|
|
92
98
|
* (inbound messages), `to` is write-side (outbound). Adds a "ready"
|
|
@@ -109,19 +115,19 @@ export function bridge(parameters) {
|
|
|
109
115
|
from_.destroy();
|
|
110
116
|
to.destroy();
|
|
111
117
|
if (pending)
|
|
112
|
-
rejectReady();
|
|
118
|
+
rejectReady(new BridgeDestroyedError());
|
|
113
119
|
},
|
|
114
120
|
on(topic, listener, id) {
|
|
115
121
|
return from_.on(topic, listener, id);
|
|
116
122
|
},
|
|
117
123
|
async send(topic, payload, targetOrigin) {
|
|
118
|
-
pending =
|
|
124
|
+
pending = waitForReady;
|
|
119
125
|
if (waitForReady)
|
|
120
126
|
await readyPromise.finally(() => (pending = false));
|
|
121
127
|
return to.send(topic, payload, targetOrigin);
|
|
122
128
|
},
|
|
123
129
|
async sendAsync(topic, payload, targetOrigin) {
|
|
124
|
-
pending =
|
|
130
|
+
pending = waitForReady;
|
|
125
131
|
if (waitForReady)
|
|
126
132
|
await readyPromise.finally(() => (pending = false));
|
|
127
133
|
return to.sendAsync(topic, payload, targetOrigin);
|
|
@@ -13,6 +13,7 @@ export type { Bridge, BridgeParameters, FlowAccount, FlowRemote, FlowRemoteConfi
|
|
|
13
13
|
export type { OtpVerificationFailure, OtpVerificationResult, VerificationAdapter, } from "./otp";
|
|
14
14
|
export type { Call, ConnectCapabilities, ConnectRequest, ConnectResponse, GuestRequest, GuestResponse, MethodName, MethodParams, MethodResult, RestoreResponse, RpcRequest, SendCallsParams, SendCallsRequest, SendCallsResponse, SendTransactionParams, SendTransactionRequest, SendTransactionResponse, SignMessageRequest, SignMessageResponse, SignOutRequest, SignOutResponse, SignTypedDataRequest, SignTypedDataResponse, TransactionArgs, TypedData, TypedDataDomain, TypedDataField, } from "./protocol";
|
|
15
15
|
export { getConnectCapabilities, isPersonalSignParams, isSendCallsParams, isSendTransactionParams, } from "./protocol";
|
|
16
|
+
export type { ReportOperation, ReportRequest, ReportResponse, ReportsApi, ReportTransport, } from "./reports";
|
|
16
17
|
export type { CreateRoomEventInput, RoomEventArchive, RoomEventAttendance, RoomEventFrequency, RoomEventInstance, RoomEventInterest, RoomEventInterestState, RoomEventList, RoomEventOccurrence, RoomEventRecurrence, RoomEventRoomRef, RoomEventRun, RoomEventSeries, RoomEventStatus, SetInterestInput, UpdateRoomEventInput, } from "./room-events";
|
|
17
18
|
export type { CreateRoomInput, GlobalRole, ModerationSubject, MyRooms, PlayerPositionReport, RoleChangeVerdict, RoomCapabilities, RoomCapability, RoomChannel, RoomDetail, RoomList, RoomMemberEntry, RoomMembers, RoomOccupancy, RoomOwner, RoomPlayerPosition, RoomPresenceEntry, RoomPresenceSnapshot, RoomRestrictionKind, RoomRole, RoomSummary, RoomSurfaceSettings, RoomsApi, RoomVisibility, StaffEntry, UpdateRoomInput, VerifyRoomContext, Viewer, VoiceDecisionReason, VoiceDecisionSubject, VoiceRoomDecision, } from "./rooms";
|
|
18
19
|
export type { AccessKeyOptions, AccessKeyPreparation, Address, ColorScheme, CreateDialogHostOptions, CreateFlowOptions, DialogHost, DialogOpenOptions, FinalizeAccessKeyParams, Flow, FlowConnectorParameters, FlowCookieNames, FlowIdProviderProps, FlowSessionState, FlowState, FlowWidgetHandle, FlowWidgetName, FlowWidgetProps, Listener, LoginOptions, MountFlowWidgetOptions, MountProfileOptions, OpenProfileOptions, PrepareArgsWithAuth, PrepareTransactionRequestPhase, ProfileButtonHandle, ProfileButtonProps, ProfilePosition, ResolveAccountParams, ResolvedAccessKeyOptions, RootCredential, RunLoginParams, RunLoginResult, SendCallsArgs, SendTransactionArgs, Session, SigningContext, SignMessageArgs, SignTypedDataArgs, Store, StoredAccessKey, UseOpenProfileOptions, WagmiConnectCapabilities, WagmiConnectParams, } from "./sdk";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
import type { httpOperations } from "../contracts/http";
|
|
3
|
+
export type ReportOperation = keyof typeof httpOperations;
|
|
4
|
+
export type ReportRequest<T extends ReportOperation> = z.input<(typeof httpOperations)[T]["request"]>;
|
|
5
|
+
export type ReportResponse<T extends ReportOperation> = z.output<(typeof httpOperations)[T]["response"]>;
|
|
6
|
+
export type ReportTransport = (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>;
|
|
7
|
+
export type ReportsApi = <T extends ReportOperation>(operation: T, body: ReportRequest<T>) => Promise<ReportResponse<T>>;
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flow-industries/id",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -54,10 +54,14 @@
|
|
|
54
54
|
"./focus": {
|
|
55
55
|
"types": "./dist/sdk/client/focus.d.ts",
|
|
56
56
|
"import": "./dist/sdk/client/focus.js"
|
|
57
|
-
}
|
|
57
|
+
},
|
|
58
|
+
"./contracts/v1/reports.json": "./contracts/v1/reports.json",
|
|
59
|
+
"./contracts/v1/openapi.json": "./contracts/v1/openapi.json",
|
|
60
|
+
"./contracts/v1/sdk-exports.json": "./contracts/v1/sdk-exports.json"
|
|
58
61
|
},
|
|
59
62
|
"files": [
|
|
60
|
-
"dist/sdk"
|
|
63
|
+
"dist/sdk",
|
|
64
|
+
"contracts"
|
|
61
65
|
],
|
|
62
66
|
"scripts": {
|
|
63
67
|
"dev": "./dev.sh",
|
|
@@ -71,7 +75,7 @@
|
|
|
71
75
|
"worker": "bun run src/worker.ts",
|
|
72
76
|
"db:generate": "bunx @better-auth/cli generate",
|
|
73
77
|
"db:migrate:gen": "bunx drizzle-kit generate",
|
|
74
|
-
"db:migrate": "
|
|
78
|
+
"db:migrate": "bun scripts/db-migrate.ts",
|
|
75
79
|
"db:push": "bunx drizzle-kit push",
|
|
76
80
|
"db:studio": "bunx drizzle-kit studio",
|
|
77
81
|
"usernames:refresh": "bun run scripts/generate-reserved-usernames.ts",
|
|
@@ -80,7 +84,11 @@
|
|
|
80
84
|
"test:sdk-package": "bash scripts/test-sdk-package.sh",
|
|
81
85
|
"format": "biome format --write",
|
|
82
86
|
"check": "biome check --write",
|
|
83
|
-
"typecheck": "tsr generate && tsc --noEmit"
|
|
87
|
+
"typecheck": "tsr generate && tsc --noEmit",
|
|
88
|
+
"contracts:generate": "bun scripts/generate-contracts.ts",
|
|
89
|
+
"contracts:check": "bun scripts/generate-contracts.ts --check && bun scripts/check-contract-compatibility.ts",
|
|
90
|
+
"db:check": "bun scripts/db-check.ts",
|
|
91
|
+
"test:migrations": "bun test scripts/migrations.test.ts scripts/migration-drift.test.ts"
|
|
84
92
|
},
|
|
85
93
|
"peerDependencies": {
|
|
86
94
|
"viem": ">=2.47.10",
|
|
@@ -122,7 +130,9 @@
|
|
|
122
130
|
"tailwindcss": "^4.1.18",
|
|
123
131
|
"tw-animate-css": "^1.4.0",
|
|
124
132
|
"typescript": "^5",
|
|
125
|
-
"vite": "^7.3.1"
|
|
133
|
+
"vite": "^7.3.1",
|
|
134
|
+
"react": "^19.2.4",
|
|
135
|
+
"react-dom": "^19.2.4"
|
|
126
136
|
},
|
|
127
137
|
"trustedDependencies": [
|
|
128
138
|
"esbuild",
|
|
@@ -155,8 +165,6 @@
|
|
|
155
165
|
"motion": "^12.33.0",
|
|
156
166
|
"pino": "^10.3.1",
|
|
157
167
|
"postgres": "^3.4.8",
|
|
158
|
-
"react": "^19.2.4",
|
|
159
|
-
"react-dom": "^19.2.4",
|
|
160
168
|
"react-intersection-observer": "^10.0.2",
|
|
161
169
|
"sharp": "^0.35.2",
|
|
162
170
|
"tempo.ts": "^0.14.2",
|