@tinyhumansai/tinyplace 0.1.0 → 0.1.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/package.json +2 -1
- package/src/api/a2a.ts +0 -50
- package/src/api/admin.ts +0 -95
- package/src/api/broadcasts.ts +0 -110
- package/src/api/channels.ts +0 -110
- package/src/api/directory.ts +0 -45
- package/src/api/escrow.ts +0 -163
- package/src/api/events.ts +0 -133
- package/src/api/explorer.ts +0 -48
- package/src/api/groups.ts +0 -64
- package/src/api/inbox.ts +0 -71
- package/src/api/keys.ts +0 -18
- package/src/api/ledger.ts +0 -28
- package/src/api/marketplace.ts +0 -165
- package/src/api/messages.ts +0 -23
- package/src/api/moderation.ts +0 -71
- package/src/api/payments.ts +0 -47
- package/src/api/pricing.ts +0 -122
- package/src/api/profiles.ts +0 -43
- package/src/api/registry.ts +0 -143
- package/src/api/reputation.ts +0 -60
- package/src/api/search.ts +0 -59
- package/src/api/stats.ts +0 -32
- package/src/auth.ts +0 -75
- package/src/client.ts +0 -120
- package/src/crypto.ts +0 -74
- package/src/http.ts +0 -147
- package/src/index.ts +0 -72
- package/src/local-signer.ts +0 -78
- package/src/signal/crypto.ts +0 -229
- package/src/signal/index.ts +0 -28
- package/src/signal/keys.ts +0 -54
- package/src/signal/memory-store.ts +0 -66
- package/src/signal/ratchet.ts +0 -162
- package/src/signal/session.ts +0 -189
- package/src/signal/store.ts +0 -49
- package/src/signal/x3dh.ts +0 -130
- package/src/signer.ts +0 -21
- package/src/types/broadcasts.ts +0 -81
- package/src/types/commerce.ts +0 -206
- package/src/types/directory.ts +0 -98
- package/src/types/escrow.ts +0 -163
- package/src/types/events.ts +0 -155
- package/src/types/explorer.ts +0 -152
- package/src/types/groups.ts +0 -62
- package/src/types/identity.ts +0 -113
- package/src/types/index.ts +0 -16
- package/src/types/ledger.ts +0 -78
- package/src/types/marketplace.ts +0 -166
- package/src/types/messaging.ts +0 -77
- package/src/types/payments.ts +0 -103
- package/src/types/profile.ts +0 -55
- package/src/types/reputation.ts +0 -98
- package/src/types/search.ts +0 -61
- package/src/types/social.ts +0 -186
- package/src/websocket.ts +0 -112
- package/tests/signal.test.ts +0 -353
- package/tests/staging.test.ts +0 -650
- package/tsconfig.json +0 -15
- package/vitest.config.ts +0 -7
package/src/api/pricing.ts
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import type { HttpClient } from "../http.js";
|
|
2
|
-
import type { TinyVerseWebSocket } from "../websocket.js";
|
|
3
|
-
import type {
|
|
4
|
-
BridgeExecution,
|
|
5
|
-
BridgeExecuteRequest,
|
|
6
|
-
BridgeQuote,
|
|
7
|
-
BridgeRoute,
|
|
8
|
-
GasEstimate,
|
|
9
|
-
PriceHistory,
|
|
10
|
-
PriceQuote,
|
|
11
|
-
SwapExecution,
|
|
12
|
-
SwapExecuteRequest,
|
|
13
|
-
SwapQuote,
|
|
14
|
-
TradePair,
|
|
15
|
-
} from "../types/index.js";
|
|
16
|
-
|
|
17
|
-
export class PricingApi {
|
|
18
|
-
constructor(
|
|
19
|
-
private readonly http: HttpClient,
|
|
20
|
-
private readonly wsFactory?: (path: string) => TinyVerseWebSocket,
|
|
21
|
-
) {}
|
|
22
|
-
|
|
23
|
-
// --- Price Data ---
|
|
24
|
-
|
|
25
|
-
quote(params: { base: string; quote: string; network?: string }): Promise<PriceQuote> {
|
|
26
|
-
return this.http.get<PriceQuote>("/pricing/quote", params as Record<string, unknown>);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
history(params: {
|
|
30
|
-
base: string;
|
|
31
|
-
quote: string;
|
|
32
|
-
interval: string;
|
|
33
|
-
from?: string;
|
|
34
|
-
to?: string;
|
|
35
|
-
}): Promise<PriceHistory> {
|
|
36
|
-
return this.http.get<PriceHistory>("/pricing/history", params as Record<string, unknown>);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
assets(): Promise<{ assets: Array<{ symbol: string; address?: string; decimals: number }> }> {
|
|
40
|
-
return this.http.get<{ assets: Array<{ symbol: string; address?: string; decimals: number }> }>(
|
|
41
|
-
"/pricing/assets",
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
pairs(): Promise<{ pairs: Array<TradePair> }> {
|
|
46
|
-
return this.http.get<{ pairs: Array<TradePair> }>("/pricing/pairs");
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
networks(): Promise<{ networks: Array<string> }> {
|
|
50
|
-
return this.http.get<{ networks: Array<string> }>("/pricing/networks");
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
gas(network: string): Promise<GasEstimate> {
|
|
54
|
-
return this.http.get<GasEstimate>("/pricing/gas", { network });
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
priceStream(): TinyVerseWebSocket | undefined {
|
|
58
|
-
return this.wsFactory?.("/pricing/stream");
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// --- Swap ---
|
|
62
|
-
|
|
63
|
-
swapQuote(params: {
|
|
64
|
-
fromAsset: string;
|
|
65
|
-
toAsset: string;
|
|
66
|
-
amount: string;
|
|
67
|
-
}): Promise<SwapQuote> {
|
|
68
|
-
return this.http.get<SwapQuote>("/swap/quote", params as Record<string, unknown>);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
executeSwap(request: SwapExecuteRequest): Promise<SwapExecution> {
|
|
72
|
-
return this.http.post<SwapExecution>("/swap/execute", request);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
getSwap(swapId: string): Promise<SwapExecution> {
|
|
76
|
-
return this.http.getAuth<SwapExecution>(`/swap/${encodeURIComponent(swapId)}`);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
swapHistory(params?: { limit?: number; offset?: number }): Promise<{ swaps: Array<SwapExecution> }> {
|
|
80
|
-
return this.http.getAuth<{ swaps: Array<SwapExecution> }>(
|
|
81
|
-
"/swap/history",
|
|
82
|
-
params as Record<string, unknown>,
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// --- Bridge ---
|
|
87
|
-
|
|
88
|
-
bridgeRoutes(params: { fromChain: string; toChain: string }): Promise<{ routes: Array<BridgeRoute> }> {
|
|
89
|
-
return this.http.get<{ routes: Array<BridgeRoute> }>(
|
|
90
|
-
"/bridge/routes",
|
|
91
|
-
params as Record<string, unknown>,
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
bridgeQuote(params: {
|
|
96
|
-
fromChain: string;
|
|
97
|
-
toChain: string;
|
|
98
|
-
token: string;
|
|
99
|
-
amount: string;
|
|
100
|
-
}): Promise<BridgeQuote> {
|
|
101
|
-
return this.http.get<BridgeQuote>("/bridge/quote", params as Record<string, unknown>);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
executeBridge(request: BridgeExecuteRequest): Promise<BridgeExecution> {
|
|
105
|
-
return this.http.post<BridgeExecution>("/bridge/execute", request);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
getBridge(bridgeId: string): Promise<BridgeExecution> {
|
|
109
|
-
return this.http.getAuth<BridgeExecution>(`/bridge/${encodeURIComponent(bridgeId)}`);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
bridgeHistory(params?: { limit?: number; offset?: number }): Promise<{ bridges: Array<BridgeExecution> }> {
|
|
113
|
-
return this.http.getAuth<{ bridges: Array<BridgeExecution> }>(
|
|
114
|
-
"/bridge/history",
|
|
115
|
-
params as Record<string, unknown>,
|
|
116
|
-
);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
bridgeStream(): TinyVerseWebSocket | undefined {
|
|
120
|
-
return this.wsFactory?.("/bridge/stream");
|
|
121
|
-
}
|
|
122
|
-
}
|
package/src/api/profiles.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type { HttpClient } from "../http.js";
|
|
2
|
-
import type {
|
|
3
|
-
AgentCard,
|
|
4
|
-
AgentProfile,
|
|
5
|
-
ProfileActivity,
|
|
6
|
-
ProfileAttestation,
|
|
7
|
-
ProfileBroadcast,
|
|
8
|
-
ProfileGroupMembership,
|
|
9
|
-
} from "../types/index.js";
|
|
10
|
-
|
|
11
|
-
export class ProfilesApi {
|
|
12
|
-
constructor(private readonly http: HttpClient) {}
|
|
13
|
-
|
|
14
|
-
get(username: string): Promise<AgentProfile> {
|
|
15
|
-
return this.http.get<AgentProfile>(`/profiles/${encodeURIComponent(username)}`);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
activity(username: string): Promise<ProfileActivity> {
|
|
19
|
-
return this.http.get<ProfileActivity>(`/profiles/${encodeURIComponent(username)}/activity`);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
groups(username: string): Promise<{ groups: Array<ProfileGroupMembership> }> {
|
|
23
|
-
return this.http.get<{ groups: Array<ProfileGroupMembership> }>(
|
|
24
|
-
`/profiles/${encodeURIComponent(username)}/groups`,
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
broadcasts(username: string): Promise<{ broadcasts: Array<ProfileBroadcast> }> {
|
|
29
|
-
return this.http.get<{ broadcasts: Array<ProfileBroadcast> }>(
|
|
30
|
-
`/profiles/${encodeURIComponent(username)}/broadcasts`,
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
attestations(username: string): Promise<{ attestations: Array<ProfileAttestation> }> {
|
|
35
|
-
return this.http.get<{ attestations: Array<ProfileAttestation> }>(
|
|
36
|
-
`/profiles/${encodeURIComponent(username)}/attestations`,
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
agentCard(username: string): Promise<AgentCard> {
|
|
41
|
-
return this.http.get<AgentCard>(`/profiles/${encodeURIComponent(username)}/agentCard`);
|
|
42
|
-
}
|
|
43
|
-
}
|
package/src/api/registry.ts
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import type { SigningKey } from "../auth.js";
|
|
2
|
-
import { signCanonicalPayload } from "../auth.js";
|
|
3
|
-
import { canonicalPayload } from "../crypto.js";
|
|
4
|
-
import type { HttpClient } from "../http.js";
|
|
5
|
-
import type {
|
|
6
|
-
AvailabilityResponse,
|
|
7
|
-
Identity,
|
|
8
|
-
IdentityClaimRequest,
|
|
9
|
-
IdentityExport,
|
|
10
|
-
IdentityMetadata,
|
|
11
|
-
IdentityProfileUpdate,
|
|
12
|
-
LedgerTransaction,
|
|
13
|
-
PaymentMethod,
|
|
14
|
-
ProfileVisibilityUpdate,
|
|
15
|
-
RenewalRequest,
|
|
16
|
-
Subname,
|
|
17
|
-
SubnameCreateRequest,
|
|
18
|
-
} from "../types/index.js";
|
|
19
|
-
|
|
20
|
-
export interface RegisterRequest {
|
|
21
|
-
username: string;
|
|
22
|
-
bio: string;
|
|
23
|
-
cryptoId: string;
|
|
24
|
-
publicKey: string;
|
|
25
|
-
paymentMethods?: Array<PaymentMethod>;
|
|
26
|
-
metadata?: IdentityMetadata;
|
|
27
|
-
payment?: Record<string, string>;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export class RegistryApi {
|
|
31
|
-
constructor(
|
|
32
|
-
private readonly http: HttpClient,
|
|
33
|
-
private readonly signingKey?: SigningKey,
|
|
34
|
-
) {}
|
|
35
|
-
|
|
36
|
-
async register(request: RegisterRequest): Promise<Identity> {
|
|
37
|
-
const payload = canonicalPayload("identity.register", {
|
|
38
|
-
bio: request.bio,
|
|
39
|
-
cryptoId: request.cryptoId,
|
|
40
|
-
metadata: request.metadata,
|
|
41
|
-
paymentMethods: request.paymentMethods,
|
|
42
|
-
publicKey: request.publicKey,
|
|
43
|
-
username: request.username,
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
let signature: string | undefined;
|
|
47
|
-
if (this.signingKey) {
|
|
48
|
-
signature = await signCanonicalPayload(this.signingKey, payload);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return this.http.postPublic<Identity>("/registry/names", {
|
|
52
|
-
...request,
|
|
53
|
-
signature,
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
get(name: string): Promise<AvailabilityResponse> {
|
|
58
|
-
return this.http.get<AvailabilityResponse>(`/registry/names/${encodeURIComponent(name)}`);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export(name: string): Promise<IdentityExport> {
|
|
62
|
-
return this.http.get<IdentityExport>(`/registry/names/${encodeURIComponent(name)}/export`);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
async updateProfile(name: string, update: IdentityProfileUpdate): Promise<Identity> {
|
|
66
|
-
if (this.signingKey && !update.signature) {
|
|
67
|
-
const payload = canonicalPayload("identity.profile", {
|
|
68
|
-
bio: update.bio,
|
|
69
|
-
metadata: update.metadata,
|
|
70
|
-
username: name,
|
|
71
|
-
});
|
|
72
|
-
update = { ...update, signature: await signCanonicalPayload(this.signingKey, payload) };
|
|
73
|
-
}
|
|
74
|
-
return this.http.put<Identity>(
|
|
75
|
-
`/registry/names/${encodeURIComponent(name)}/profile`,
|
|
76
|
-
update,
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
updateProfileVisibility(name: string, update: ProfileVisibilityUpdate): Promise<Identity> {
|
|
81
|
-
return this.http.put<Identity>(
|
|
82
|
-
`/registry/names/${encodeURIComponent(name)}/profile-visibility`,
|
|
83
|
-
update,
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
async renew(name: string, request: RenewalRequest): Promise<LedgerTransaction> {
|
|
88
|
-
if (this.signingKey && !request.signature) {
|
|
89
|
-
const payload = canonicalPayload("identity.renew", { username: name });
|
|
90
|
-
request = { ...request, signature: await signCanonicalPayload(this.signingKey, payload) };
|
|
91
|
-
}
|
|
92
|
-
return this.http.post<LedgerTransaction>(
|
|
93
|
-
`/registry/names/${encodeURIComponent(name)}/renew`,
|
|
94
|
-
request,
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
async claim(name: string, request: IdentityClaimRequest): Promise<LedgerTransaction> {
|
|
99
|
-
if (this.signingKey && !request.signature) {
|
|
100
|
-
const payload = canonicalPayload("identity.claim", {
|
|
101
|
-
cryptoId: request.cryptoId,
|
|
102
|
-
publicKey: request.publicKey,
|
|
103
|
-
username: name,
|
|
104
|
-
});
|
|
105
|
-
request = { ...request, signature: await signCanonicalPayload(this.signingKey, payload) };
|
|
106
|
-
}
|
|
107
|
-
return this.http.post<LedgerTransaction>(
|
|
108
|
-
`/registry/names/${encodeURIComponent(name)}/claim`,
|
|
109
|
-
request,
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
async createSubname(name: string, request: SubnameCreateRequest): Promise<Subname> {
|
|
114
|
-
if (this.signingKey && !request.signature) {
|
|
115
|
-
const payload = canonicalPayload("identity.subname.create", {
|
|
116
|
-
bio: request.bio,
|
|
117
|
-
subname: request.subname,
|
|
118
|
-
target: request.target,
|
|
119
|
-
username: name,
|
|
120
|
-
});
|
|
121
|
-
request = { ...request, signature: await signCanonicalPayload(this.signingKey, payload) };
|
|
122
|
-
}
|
|
123
|
-
return this.http.post<Subname>(
|
|
124
|
-
`/registry/names/${encodeURIComponent(name)}/subnames`,
|
|
125
|
-
request,
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
async deleteSubname(name: string, subname: string): Promise<void> {
|
|
130
|
-
let body: Record<string, string> | undefined;
|
|
131
|
-
if (this.signingKey) {
|
|
132
|
-
const payload = canonicalPayload("identity.subname.delete", {
|
|
133
|
-
subname,
|
|
134
|
-
username: name,
|
|
135
|
-
});
|
|
136
|
-
body = { signature: await signCanonicalPayload(this.signingKey, payload) };
|
|
137
|
-
}
|
|
138
|
-
return this.http.delete<void>(
|
|
139
|
-
`/registry/names/${encodeURIComponent(name)}/subnames/${encodeURIComponent(subname)}`,
|
|
140
|
-
body,
|
|
141
|
-
);
|
|
142
|
-
}
|
|
143
|
-
}
|
package/src/api/reputation.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import type { HttpClient } from "../http.js";
|
|
2
|
-
import type {
|
|
3
|
-
Attestation,
|
|
4
|
-
AttestationCreate,
|
|
5
|
-
LeaderboardResponse,
|
|
6
|
-
ReputationHistoryPoint,
|
|
7
|
-
ReputationReview,
|
|
8
|
-
ReputationReviewCreate,
|
|
9
|
-
ReputationScore,
|
|
10
|
-
} from "../types/index.js";
|
|
11
|
-
|
|
12
|
-
export class ReputationApi {
|
|
13
|
-
constructor(private readonly http: HttpClient) {}
|
|
14
|
-
|
|
15
|
-
getScore(agentId: string): Promise<ReputationScore> {
|
|
16
|
-
return this.http.get<ReputationScore>(`/reputation/${encodeURIComponent(agentId)}`);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
getHistory(agentId: string): Promise<{ history: Array<ReputationHistoryPoint> }> {
|
|
20
|
-
return this.http.get<{ history: Array<ReputationHistoryPoint> }>(
|
|
21
|
-
`/reputation/${encodeURIComponent(agentId)}/history`,
|
|
22
|
-
);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
getReviews(agentId: string): Promise<{ reviews: Array<ReputationReview> }> {
|
|
26
|
-
return this.http.get<{ reviews: Array<ReputationReview> }>(
|
|
27
|
-
`/reputation/${encodeURIComponent(agentId)}/reviews`,
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
getAttestations(agentId: string): Promise<{ attestations: Array<Attestation> }> {
|
|
32
|
-
return this.http.get<{ attestations: Array<Attestation> }>(
|
|
33
|
-
`/reputation/${encodeURIComponent(agentId)}/attestations`,
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
createReview(review: ReputationReviewCreate): Promise<ReputationReview> {
|
|
38
|
-
return this.http.post<ReputationReview>("/reputation/reviews", review);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
createAttestation(attestation: AttestationCreate): Promise<Attestation> {
|
|
42
|
-
return this.http.post<Attestation>("/reputation/attestations", attestation);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
deleteAttestation(attestationId: string): Promise<void> {
|
|
46
|
-
return this.http.delete<void>(
|
|
47
|
-
`/reputation/attestations/${encodeURIComponent(attestationId)}`,
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
leaderboard(
|
|
52
|
-
category?: string,
|
|
53
|
-
params?: { limit?: number; period?: string; sort?: string },
|
|
54
|
-
): Promise<LeaderboardResponse> {
|
|
55
|
-
return this.http.get<LeaderboardResponse>(
|
|
56
|
-
category ? `/leaderboards/${encodeURIComponent(category)}` : "/leaderboards/reputation",
|
|
57
|
-
params as Record<string, unknown>,
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
}
|
package/src/api/search.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { HttpClient } from "../http.js";
|
|
2
|
-
import type {
|
|
3
|
-
DiscoverResponse,
|
|
4
|
-
DiscoveryCategory,
|
|
5
|
-
SearchResponse,
|
|
6
|
-
SuggestResponse,
|
|
7
|
-
} from "../types/index.js";
|
|
8
|
-
|
|
9
|
-
export class SearchApi {
|
|
10
|
-
constructor(private readonly http: HttpClient) {}
|
|
11
|
-
|
|
12
|
-
unified(query: string): Promise<SearchResponse> {
|
|
13
|
-
return this.http.get<SearchResponse>("/search", { q: query });
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
agents(params: { q?: string; skill?: string; tag?: string; limit?: number; cursor?: string }): Promise<SearchResponse> {
|
|
17
|
-
return this.http.get<SearchResponse>("/search/agents", params as Record<string, unknown>);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
groups(params: { q?: string; tag?: string; limit?: number }): Promise<SearchResponse> {
|
|
21
|
-
return this.http.get<SearchResponse>("/search/groups", params as Record<string, unknown>);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
channels(params: { q?: string; tag?: string; limit?: number }): Promise<SearchResponse> {
|
|
25
|
-
return this.http.get<SearchResponse>("/search/channels", params as Record<string, unknown>);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
broadcasts(params: { q?: string; tag?: string; limit?: number }): Promise<SearchResponse> {
|
|
29
|
-
return this.http.get<SearchResponse>("/search/broadcasts", params as Record<string, unknown>);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
events(params: { q?: string; tag?: string; limit?: number }): Promise<SearchResponse> {
|
|
33
|
-
return this.http.get<SearchResponse>("/search/events", params as Record<string, unknown>);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
products(params: { q?: string; category?: string; limit?: number }): Promise<SearchResponse> {
|
|
37
|
-
return this.http.get<SearchResponse>("/search/products", params as Record<string, unknown>);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
suggest(query: string): Promise<SuggestResponse> {
|
|
41
|
-
return this.http.get<SuggestResponse>("/search/suggest", { q: query });
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
trending(limit?: number): Promise<DiscoverResponse> {
|
|
45
|
-
return this.http.get<DiscoverResponse>("/discover/trending", { limit });
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
newest(limit?: number): Promise<DiscoverResponse> {
|
|
49
|
-
return this.http.get<DiscoverResponse>("/discover/new", { limit });
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
recommended(limit?: number): Promise<DiscoverResponse> {
|
|
53
|
-
return this.http.getAuth<DiscoverResponse>("/discover/recommended", { limit });
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
categories(): Promise<{ categories: Array<DiscoveryCategory> }> {
|
|
57
|
-
return this.http.get<{ categories: Array<DiscoveryCategory> }>("/discover/categories");
|
|
58
|
-
}
|
|
59
|
-
}
|
package/src/api/stats.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { HttpClient } from "../http.js";
|
|
2
|
-
import type {
|
|
3
|
-
AgentStats,
|
|
4
|
-
FeeStats,
|
|
5
|
-
StatsSnapshot,
|
|
6
|
-
TransactionStats,
|
|
7
|
-
VolumeStats,
|
|
8
|
-
} from "../types/index.js";
|
|
9
|
-
|
|
10
|
-
export class StatsApi {
|
|
11
|
-
constructor(private readonly http: HttpClient) {}
|
|
12
|
-
|
|
13
|
-
overview(): Promise<StatsSnapshot> {
|
|
14
|
-
return this.http.get<StatsSnapshot>("/stats");
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
agents(): Promise<AgentStats> {
|
|
18
|
-
return this.http.get<AgentStats>("/stats/agents");
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
transactions(): Promise<TransactionStats> {
|
|
22
|
-
return this.http.get<TransactionStats>("/stats/transactions");
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
volume(): Promise<VolumeStats> {
|
|
26
|
-
return this.http.get<VolumeStats>("/stats/volume");
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
fees(): Promise<FeeStats> {
|
|
30
|
-
return this.http.get<FeeStats>("/stats/fees");
|
|
31
|
-
}
|
|
32
|
-
}
|
package/src/auth.ts
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { sha256Hex } from "./crypto.js";
|
|
2
|
-
|
|
3
|
-
export interface SigningKey {
|
|
4
|
-
agentId: string;
|
|
5
|
-
sign(data: Uint8Array): Promise<Uint8Array> | Uint8Array;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface AuthHeaders {
|
|
9
|
-
Authorization: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function toBase64(bytes: Uint8Array): string {
|
|
13
|
-
let binary = "";
|
|
14
|
-
for (const byte of bytes) {
|
|
15
|
-
binary += String.fromCharCode(byte);
|
|
16
|
-
}
|
|
17
|
-
return btoa(binary);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function buildAuthHeader(
|
|
21
|
-
agentId: string,
|
|
22
|
-
signature: string,
|
|
23
|
-
timestamp: string,
|
|
24
|
-
): AuthHeaders {
|
|
25
|
-
return {
|
|
26
|
-
Authorization: `tiny.place ${agentId}:${signature}:${timestamp}`,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export async function signRequest(
|
|
31
|
-
key: SigningKey,
|
|
32
|
-
body: string,
|
|
33
|
-
): Promise<AuthHeaders> {
|
|
34
|
-
const timestamp = new Date().toISOString();
|
|
35
|
-
const payload = new TextEncoder().encode(body + timestamp);
|
|
36
|
-
const signature = await key.sign(payload);
|
|
37
|
-
return buildAuthHeader(key.agentId, toBase64(signature), timestamp);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export interface DirectoryWriteHeaders {
|
|
41
|
-
"X-TinyPlace-Date": string;
|
|
42
|
-
"X-TinyPlace-Public-Key": string;
|
|
43
|
-
"X-TinyPlace-Signature": string;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export async function signDirectoryWrite(
|
|
47
|
-
key: SigningKey,
|
|
48
|
-
publicKeyBase64: string,
|
|
49
|
-
method: string,
|
|
50
|
-
requestUri: string,
|
|
51
|
-
body: Uint8Array | string,
|
|
52
|
-
): Promise<DirectoryWriteHeaders> {
|
|
53
|
-
const timestamp = new Date().toISOString();
|
|
54
|
-
const bodyBytes =
|
|
55
|
-
typeof body === "string" ? new TextEncoder().encode(body) : body;
|
|
56
|
-
const bodyHash = sha256Hex(bodyBytes);
|
|
57
|
-
const signingPayload = `${method}\n${requestUri}\n${timestamp}\n${bodyHash}`;
|
|
58
|
-
const signature = await key.sign(
|
|
59
|
-
new TextEncoder().encode(signingPayload),
|
|
60
|
-
);
|
|
61
|
-
return {
|
|
62
|
-
"X-TinyPlace-Date": timestamp,
|
|
63
|
-
"X-TinyPlace-Public-Key": publicKeyBase64,
|
|
64
|
-
"X-TinyPlace-Signature": toBase64(signature),
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export async function signCanonicalPayload(
|
|
69
|
-
key: SigningKey,
|
|
70
|
-
payload: string,
|
|
71
|
-
): Promise<string> {
|
|
72
|
-
const payloadBytes = new TextEncoder().encode(payload);
|
|
73
|
-
const signature = await key.sign(payloadBytes);
|
|
74
|
-
return toBase64(signature);
|
|
75
|
-
}
|
package/src/client.ts
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import type { SigningKey } from "./auth.js";
|
|
2
|
-
import { Signer } from "./signer.js";
|
|
3
|
-
import { HttpClient } from "./http.js";
|
|
4
|
-
import { TinyVerseWebSocket } from "./websocket.js";
|
|
5
|
-
import { A2AApi } from "./api/a2a.js";
|
|
6
|
-
import { AdminApi } from "./api/admin.js";
|
|
7
|
-
import { BroadcastsApi } from "./api/broadcasts.js";
|
|
8
|
-
import { ChannelsApi } from "./api/channels.js";
|
|
9
|
-
import { DirectoryApi } from "./api/directory.js";
|
|
10
|
-
import { EscrowApi } from "./api/escrow.js";
|
|
11
|
-
import { EventsApi } from "./api/events.js";
|
|
12
|
-
import { ExplorerApi } from "./api/explorer.js";
|
|
13
|
-
import { GroupsApi } from "./api/groups.js";
|
|
14
|
-
import { InboxApi } from "./api/inbox.js";
|
|
15
|
-
import { KeysApi } from "./api/keys.js";
|
|
16
|
-
import { LedgerApi } from "./api/ledger.js";
|
|
17
|
-
import { MarketplaceApi } from "./api/marketplace.js";
|
|
18
|
-
import { MessagesApi } from "./api/messages.js";
|
|
19
|
-
import { ModerationApi } from "./api/moderation.js";
|
|
20
|
-
import { PaymentsApi } from "./api/payments.js";
|
|
21
|
-
import { PricingApi } from "./api/pricing.js";
|
|
22
|
-
import { ProfilesApi } from "./api/profiles.js";
|
|
23
|
-
import { RegistryApi } from "./api/registry.js";
|
|
24
|
-
import { ReputationApi } from "./api/reputation.js";
|
|
25
|
-
import { SearchApi } from "./api/search.js";
|
|
26
|
-
import { StatsApi } from "./api/stats.js";
|
|
27
|
-
|
|
28
|
-
export interface TinyVerseClientOptions {
|
|
29
|
-
baseUrl: string;
|
|
30
|
-
signer?: Signer;
|
|
31
|
-
/** @deprecated Use `signer` instead. */
|
|
32
|
-
signingKey?: SigningKey;
|
|
33
|
-
/** @deprecated Use `signer` instead. */
|
|
34
|
-
publicKeyBase64?: string;
|
|
35
|
-
fetch?: typeof globalThis.fetch;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export class TinyVerseClient {
|
|
39
|
-
private readonly http: HttpClient;
|
|
40
|
-
private readonly baseUrl: string;
|
|
41
|
-
private readonly signingKey?: SigningKey;
|
|
42
|
-
|
|
43
|
-
readonly registry: RegistryApi;
|
|
44
|
-
readonly keys: KeysApi;
|
|
45
|
-
readonly messages: MessagesApi;
|
|
46
|
-
readonly directory: DirectoryApi;
|
|
47
|
-
readonly groups: GroupsApi;
|
|
48
|
-
readonly payments: PaymentsApi;
|
|
49
|
-
readonly ledger: LedgerApi;
|
|
50
|
-
readonly reputation: ReputationApi;
|
|
51
|
-
readonly inbox: InboxApi;
|
|
52
|
-
readonly channels: ChannelsApi;
|
|
53
|
-
readonly broadcasts: BroadcastsApi;
|
|
54
|
-
readonly events: EventsApi;
|
|
55
|
-
readonly marketplace: MarketplaceApi;
|
|
56
|
-
readonly escrow: EscrowApi;
|
|
57
|
-
readonly search: SearchApi;
|
|
58
|
-
readonly profiles: ProfilesApi;
|
|
59
|
-
readonly explorer: ExplorerApi;
|
|
60
|
-
readonly pricing: PricingApi;
|
|
61
|
-
readonly moderation: ModerationApi;
|
|
62
|
-
readonly stats: StatsApi;
|
|
63
|
-
readonly admin: AdminApi;
|
|
64
|
-
readonly a2a: A2AApi;
|
|
65
|
-
|
|
66
|
-
constructor(options: TinyVerseClientOptions) {
|
|
67
|
-
this.baseUrl = options.baseUrl.replace(/\/+$/, "");
|
|
68
|
-
|
|
69
|
-
const signingKey = options.signer ?? options.signingKey;
|
|
70
|
-
const publicKeyBase64 =
|
|
71
|
-
options.signer?.publicKeyBase64 ?? options.publicKeyBase64;
|
|
72
|
-
|
|
73
|
-
this.signingKey = signingKey;
|
|
74
|
-
this.http = new HttpClient({
|
|
75
|
-
baseUrl: this.baseUrl,
|
|
76
|
-
signingKey,
|
|
77
|
-
publicKeyBase64,
|
|
78
|
-
fetch: options.fetch,
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
const wsFactory = (path: string): TinyVerseWebSocket => {
|
|
82
|
-
const wsBase = this.baseUrl.replace(/^http/, "ws");
|
|
83
|
-
return new TinyVerseWebSocket({
|
|
84
|
-
url: `${wsBase}${path}`,
|
|
85
|
-
signingKey: this.signingKey,
|
|
86
|
-
});
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
this.registry = new RegistryApi(this.http, signingKey);
|
|
90
|
-
this.keys = new KeysApi(this.http);
|
|
91
|
-
this.messages = new MessagesApi(this.http);
|
|
92
|
-
this.directory = new DirectoryApi(this.http);
|
|
93
|
-
this.groups = new GroupsApi(this.http);
|
|
94
|
-
this.payments = new PaymentsApi(this.http);
|
|
95
|
-
this.ledger = new LedgerApi(this.http);
|
|
96
|
-
this.reputation = new ReputationApi(this.http);
|
|
97
|
-
this.inbox = new InboxApi(this.http, wsFactory);
|
|
98
|
-
this.channels = new ChannelsApi(this.http, wsFactory);
|
|
99
|
-
this.broadcasts = new BroadcastsApi(this.http, wsFactory);
|
|
100
|
-
this.events = new EventsApi(this.http);
|
|
101
|
-
this.marketplace = new MarketplaceApi(this.http);
|
|
102
|
-
this.escrow = new EscrowApi(this.http);
|
|
103
|
-
this.search = new SearchApi(this.http);
|
|
104
|
-
this.profiles = new ProfilesApi(this.http);
|
|
105
|
-
this.explorer = new ExplorerApi(this.http, wsFactory);
|
|
106
|
-
this.pricing = new PricingApi(this.http, wsFactory);
|
|
107
|
-
this.moderation = new ModerationApi(this.http);
|
|
108
|
-
this.stats = new StatsApi(this.http);
|
|
109
|
-
this.admin = new AdminApi(this.http);
|
|
110
|
-
this.a2a = new A2AApi(this.http, wsFactory);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
healthz(): Promise<unknown> {
|
|
114
|
-
return this.http.get<unknown>("/healthz");
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
spec(): Promise<unknown> {
|
|
118
|
-
return this.http.get<unknown>("/spec");
|
|
119
|
-
}
|
|
120
|
-
}
|