Skip to content

Commit 7757b5c

Browse files
chore: sync from internal
1 parent f4a951d commit 7757b5c

44 files changed

Lines changed: 253 additions & 308 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/api-key-stamper/CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# @phantom/api-key-stamper
22

3+
## 2.0.1
4+
5+
### Patch Changes
6+
7+
- f59f462: Don't fetch all wallets
8+
- Updated dependencies [f59f462]
9+
- @phantom/base64url@2.0.1
10+
- @phantom/constants@2.0.1
11+
- @phantom/crypto@2.0.1
12+
- @phantom/sdk-types@2.0.1
13+
314
## 2.0.0-beta.0
415

516
### Major Changes

packages/api-key-stamper/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@phantom/api-key-stamper",
3-
"version": "2.0.0",
3+
"version": "2.0.1",
44
"description": "API key stamper for Phantom Wallet SDK",
55
"repository": {
66
"type": "git",

packages/auth2/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# @phantom/auth2
22

3+
## 2.0.1
4+
5+
### Patch Changes
6+
7+
- f59f462: Don't fetch all wallets
8+
- Updated dependencies [f59f462]
9+
- @phantom/base64url@2.0.1
10+
- @phantom/crypto@2.0.1
11+
- @phantom/sdk-types@2.0.1
12+
313
## 2.0.0-beta.0
414

515
### Major Changes

packages/auth2/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@phantom/auth2",
3-
"version": "2.0.0",
3+
"version": "2.0.1",
44
"description": "Shared core utilities for the Auth2 OAuth2 PKCE flow",
55
"repository": {
66
"type": "git",

packages/auth2/src/Auth2KmsRpcClient.ts

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@ import {
22
Configuration,
33
KMSRPCApi,
44
GetOrCreatePhantomOrganizationMethodEnum,
5-
GetOrganizationWalletsMethodEnum,
65
GetOrCreateWalletWithTagMethodEnum,
76
type KmsRpcRequest,
87
type KmsRpcResponseV2,
98
type ExternalKmsOrganization,
10-
type OrganizationWallets,
119
type KmsWalletWithDerivedAccounts,
1210
type DerivationInfoSchema,
1311
} from "@phantom/openapi-wallet-service";
@@ -17,9 +15,6 @@ import type { Auth2StamperWithKeyManagement } from "./index";
1715

1816
const DEFAULT_KMS_API_VERSION = "2025-11-24";
1917

20-
const ORGANIZATION_WALLETS_LIMIT = 20;
21-
const ORGANIZATION_WALLETS_OFFSET = 0;
22-
2318
export type Auth2KmsClientOptions = {
2419
apiBaseUrl: string;
2520
appId: string;
@@ -107,30 +102,6 @@ export class Auth2KmsRpcClient {
107102
} as unknown as KmsRpcRequest);
108103
}
109104

110-
public async getOrganizationWallets(organizationId: string): Promise<OrganizationWallets> {
111-
const allWallets: OrganizationWallets["wallets"] = [];
112-
let offset = ORGANIZATION_WALLETS_OFFSET;
113-
let page: OrganizationWallets;
114-
115-
do {
116-
page = await this.postKmsRpc<OrganizationWallets>({
117-
method: GetOrganizationWalletsMethodEnum.getOrganizationWallets,
118-
params: { organizationId, limit: ORGANIZATION_WALLETS_LIMIT, offset },
119-
timestampMs: Date.now(),
120-
} as KmsRpcRequest);
121-
122-
allWallets.push(...page.wallets);
123-
offset += ORGANIZATION_WALLETS_LIMIT;
124-
} while (page.wallets.length === ORGANIZATION_WALLETS_LIMIT);
125-
126-
return {
127-
wallets: allWallets,
128-
limit: allWallets.length,
129-
offset: 0,
130-
totalCount: allWallets.length,
131-
};
132-
}
133-
134105
public async getOrCreateWalletWithTag(args: {
135106
organizationId: string;
136107
walletName: string;

packages/auth2/src/__tests__/Auth2KmsRpcClient.test.ts

Lines changed: 0 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ jest.mock("@phantom/openapi-wallet-service", () => ({
1010
GetOrCreatePhantomOrganizationMethodEnum: {
1111
getOrCreatePhantomOrganization: "getOrCreatePhantomOrganization",
1212
},
13-
GetOrganizationWalletsMethodEnum: { getOrganizationWallets: "getOrganizationWallets" },
1413
GetOrCreateWalletWithTagMethodEnum: { getOrCreateWalletWithTag: "getOrCreateWalletWithTag" },
1514
DerivationInfoCurveEnum: { ed25519: "ed25519", secp256k1: "secp256k1" },
1615
DerivationInfoAddressFormatEnum: {
@@ -277,116 +276,6 @@ describe("Auth2KmsRpcClient", () => {
277276
});
278277
});
279278

280-
describe("getOrganizationWallets", () => {
281-
it("returns the OrganizationWallets result", async () => {
282-
mockPostKmsRpc.mockResolvedValueOnce({
283-
data: { result: { wallets: [{ walletId: "w-1", tags: ["vault"] }] } },
284-
});
285-
const client = makeClient();
286-
287-
const result = await client.getOrganizationWallets("org-abc");
288-
expect(result.wallets).toHaveLength(1);
289-
expect(result.wallets[0].walletId).toBe("w-1");
290-
});
291-
292-
it("passes organizationId, limit=20, and offset=0 in the RPC params", async () => {
293-
mockPostKmsRpc.mockResolvedValueOnce({ data: { result: { wallets: [] } } });
294-
const client = makeClient();
295-
296-
await client.getOrganizationWallets("org-abc");
297-
298-
const request = mockPostKmsRpc.mock.calls[0][0] as {
299-
method: string;
300-
params: { organizationId: string; limit: number; offset: number };
301-
};
302-
expect(request.method).toBe("getOrganizationWallets");
303-
expect(request.params.organizationId).toBe("org-abc");
304-
expect(request.params.limit).toBe(20);
305-
expect(request.params.offset).toBe(0);
306-
});
307-
308-
it("returns an empty wallets array when none exist", async () => {
309-
mockPostKmsRpc.mockResolvedValueOnce({ data: { result: { wallets: [] } } });
310-
const client = makeClient();
311-
312-
const result = await client.getOrganizationWallets("org-abc");
313-
expect(result.wallets).toEqual([]);
314-
});
315-
316-
it("makes a second request when the first page is full (length === limit)", async () => {
317-
const fullPage = Array.from({ length: 20 }, (_, i) => ({ walletId: `w-${i}`, tags: [] }));
318-
const partialPage = [{ walletId: "w-20", tags: [] }];
319-
mockPostKmsRpc
320-
.mockResolvedValueOnce({ data: { result: { wallets: fullPage } } })
321-
.mockResolvedValueOnce({ data: { result: { wallets: partialPage } } });
322-
const client = makeClient();
323-
324-
const result = await client.getOrganizationWallets("org-abc");
325-
326-
expect(mockPostKmsRpc).toHaveBeenCalledTimes(2);
327-
expect(result.wallets).toHaveLength(21);
328-
});
329-
330-
it("uses offset=0 for the first page and offset=20 for the second", async () => {
331-
const fullPage = Array.from({ length: 20 }, (_, i) => ({ walletId: `w-${i}`, tags: [] }));
332-
mockPostKmsRpc
333-
.mockResolvedValueOnce({ data: { result: { wallets: fullPage } } })
334-
.mockResolvedValueOnce({ data: { result: { wallets: [] } } });
335-
const client = makeClient();
336-
337-
await client.getOrganizationWallets("org-abc");
338-
339-
const firstCall = mockPostKmsRpc.mock.calls[0][0] as { params: { offset: number } };
340-
const secondCall = mockPostKmsRpc.mock.calls[1][0] as { params: { offset: number } };
341-
expect(firstCall.params.offset).toBe(0);
342-
expect(secondCall.params.offset).toBe(20);
343-
});
344-
345-
it("accumulates wallets across multiple full pages", async () => {
346-
const page1 = Array.from({ length: 20 }, (_, i) => ({ walletId: `w-${i}`, tags: [] }));
347-
const page2 = Array.from({ length: 20 }, (_, i) => ({ walletId: `w-${i + 20}`, tags: [] }));
348-
const page3 = [{ walletId: "w-40", tags: ["my-app"] }];
349-
mockPostKmsRpc
350-
.mockResolvedValueOnce({ data: { result: { wallets: page1 } } })
351-
.mockResolvedValueOnce({ data: { result: { wallets: page2 } } })
352-
.mockResolvedValueOnce({ data: { result: { wallets: page3 } } });
353-
const client = makeClient();
354-
355-
const result = await client.getOrganizationWallets("org-abc");
356-
357-
expect(mockPostKmsRpc).toHaveBeenCalledTimes(3);
358-
expect(result.wallets).toHaveLength(41);
359-
expect(result.wallets[40].walletId).toBe("w-40");
360-
});
361-
362-
it("stops after a page with exactly one fewer wallet than the limit", async () => {
363-
const almostFull = Array.from({ length: 19 }, (_, i) => ({ walletId: `w-${i}`, tags: [] }));
364-
mockPostKmsRpc.mockResolvedValueOnce({ data: { result: { wallets: almostFull } } });
365-
const client = makeClient();
366-
367-
await client.getOrganizationWallets("org-abc");
368-
369-
expect(mockPostKmsRpc).toHaveBeenCalledTimes(1);
370-
});
371-
372-
it("throws on KMS-level RPC error", async () => {
373-
mockPostKmsRpc.mockResolvedValueOnce({ data: { error: { code: -32001, message: "Forbidden" } } });
374-
const client = makeClient();
375-
376-
await expect(client.getOrganizationWallets("org-abc")).rejects.toThrow("KMS RPC error");
377-
});
378-
379-
it("throws on KMS-level RPC error during a subsequent page fetch", async () => {
380-
const fullPage = Array.from({ length: 20 }, (_, i) => ({ walletId: `w-${i}`, tags: [] }));
381-
mockPostKmsRpc
382-
.mockResolvedValueOnce({ data: { result: { wallets: fullPage } } })
383-
.mockResolvedValueOnce({ data: { error: { code: -32001, message: "Forbidden" } } });
384-
const client = makeClient();
385-
386-
await expect(client.getOrganizationWallets("org-abc")).rejects.toThrow("KMS RPC error");
387-
});
388-
});
389-
390279
describe("getOrCreateWalletWithTag", () => {
391280
const walletArgs = {
392281
organizationId: "org-abc",

0 commit comments

Comments
 (0)