@hypercerts-org/sdk-core 0.5.0-beta.0 → 0.7.0-beta.0

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.
Files changed (57) hide show
  1. package/README.md +130 -8
  2. package/dist/index.cjs +93 -15
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.ts +64 -1
  5. package/dist/index.mjs +93 -16
  6. package/dist/index.mjs.map +1 -1
  7. package/package.json +9 -5
  8. package/.turbo/turbo-build.log +0 -40
  9. package/.turbo/turbo-test.log +0 -119
  10. package/CHANGELOG.md +0 -62
  11. package/eslint.config.mjs +0 -22
  12. package/rollup.config.js +0 -75
  13. package/src/auth/OAuthClient.ts +0 -497
  14. package/src/core/SDK.ts +0 -410
  15. package/src/core/config.ts +0 -243
  16. package/src/core/errors.ts +0 -257
  17. package/src/core/interfaces.ts +0 -324
  18. package/src/core/types.ts +0 -282
  19. package/src/errors.ts +0 -57
  20. package/src/index.ts +0 -107
  21. package/src/lexicons.ts +0 -64
  22. package/src/repository/BlobOperationsImpl.ts +0 -199
  23. package/src/repository/CollaboratorOperationsImpl.ts +0 -442
  24. package/src/repository/HypercertOperationsImpl.ts +0 -1146
  25. package/src/repository/LexiconRegistry.ts +0 -332
  26. package/src/repository/OrganizationOperationsImpl.ts +0 -282
  27. package/src/repository/ProfileOperationsImpl.ts +0 -281
  28. package/src/repository/RecordOperationsImpl.ts +0 -340
  29. package/src/repository/Repository.ts +0 -482
  30. package/src/repository/interfaces.ts +0 -909
  31. package/src/repository/types.ts +0 -111
  32. package/src/services/hypercerts/types.ts +0 -87
  33. package/src/storage/InMemorySessionStore.ts +0 -127
  34. package/src/storage/InMemoryStateStore.ts +0 -146
  35. package/src/storage.ts +0 -63
  36. package/src/testing/index.ts +0 -67
  37. package/src/testing/mocks.ts +0 -142
  38. package/src/testing/stores.ts +0 -285
  39. package/src/testing.ts +0 -64
  40. package/src/types.ts +0 -86
  41. package/tests/auth/OAuthClient.test.ts +0 -164
  42. package/tests/core/SDK.test.ts +0 -176
  43. package/tests/core/errors.test.ts +0 -81
  44. package/tests/repository/BlobOperationsImpl.test.ts +0 -155
  45. package/tests/repository/CollaboratorOperationsImpl.test.ts +0 -438
  46. package/tests/repository/HypercertOperationsImpl.test.ts +0 -652
  47. package/tests/repository/LexiconRegistry.test.ts +0 -192
  48. package/tests/repository/OrganizationOperationsImpl.test.ts +0 -240
  49. package/tests/repository/ProfileOperationsImpl.test.ts +0 -254
  50. package/tests/repository/RecordOperationsImpl.test.ts +0 -375
  51. package/tests/repository/Repository.test.ts +0 -149
  52. package/tests/utils/fixtures.ts +0 -117
  53. package/tests/utils/mocks.ts +0 -109
  54. package/tests/utils/repository-fixtures.ts +0 -78
  55. package/tsconfig.json +0 -11
  56. package/tsconfig.tsbuildinfo +0 -1
  57. package/vitest.config.ts +0 -30
@@ -1,109 +0,0 @@
1
- import type { SessionStore, StateStore, CacheInterface, LoggerInterface } from "../../src/core/interfaces.js";
2
- import type { NodeSavedSession, NodeSavedState } from "@atproto/oauth-client-node";
3
-
4
- /**
5
- * In-memory session store for testing
6
- */
7
- export class InMemorySessionStore implements SessionStore {
8
- private sessions = new Map<string, NodeSavedSession>();
9
-
10
- async get(did: string): Promise<NodeSavedSession | undefined> {
11
- return this.sessions.get(did);
12
- }
13
-
14
- async set(did: string, session: NodeSavedSession): Promise<void> {
15
- this.sessions.set(did, session);
16
- }
17
-
18
- async del(did: string): Promise<void> {
19
- this.sessions.delete(did);
20
- }
21
-
22
- clear(): void {
23
- this.sessions.clear();
24
- }
25
- }
26
-
27
- /**
28
- * In-memory state store for testing
29
- */
30
- export class InMemoryStateStore implements StateStore {
31
- private states = new Map<string, NodeSavedState>();
32
-
33
- async get(key: string): Promise<NodeSavedState | undefined> {
34
- return this.states.get(key);
35
- }
36
-
37
- async set(key: string, state: NodeSavedState): Promise<void> {
38
- this.states.set(key, state);
39
- }
40
-
41
- async del(key: string): Promise<void> {
42
- this.states.delete(key);
43
- }
44
-
45
- clear(): void {
46
- this.states.clear();
47
- }
48
- }
49
-
50
- /**
51
- * In-memory cache for testing
52
- */
53
- export class InMemoryCache implements CacheInterface {
54
- private cache = new Map<string, { value: unknown; expiresAt?: number }>();
55
-
56
- async get<T>(key: string): Promise<T | undefined> {
57
- const entry = this.cache.get(key);
58
- if (!entry) {
59
- return undefined;
60
- }
61
-
62
- if (entry.expiresAt && Date.now() > entry.expiresAt) {
63
- this.cache.delete(key);
64
- return undefined;
65
- }
66
-
67
- return entry.value as T;
68
- }
69
-
70
- async set<T>(key: string, value: T, ttlSeconds?: number): Promise<void> {
71
- const expiresAt = ttlSeconds ? Date.now() + ttlSeconds * 1000 : undefined;
72
- this.cache.set(key, { value, expiresAt });
73
- }
74
-
75
- async del(key: string): Promise<void> {
76
- this.cache.delete(key);
77
- }
78
-
79
- async clear(): Promise<void> {
80
- this.cache.clear();
81
- }
82
- }
83
-
84
- /**
85
- * Mock logger for testing
86
- */
87
- export class MockLogger implements LoggerInterface {
88
- public logs: Array<{ level: string; message: string; args: unknown[] }> = [];
89
-
90
- debug(message: string, ...args: unknown[]): void {
91
- this.logs.push({ level: "debug", message, args });
92
- }
93
-
94
- info(message: string, ...args: unknown[]): void {
95
- this.logs.push({ level: "info", message, args });
96
- }
97
-
98
- warn(message: string, ...args: unknown[]): void {
99
- this.logs.push({ level: "warn", message, args });
100
- }
101
-
102
- error(message: string, ...args: unknown[]): void {
103
- this.logs.push({ level: "error", message, args });
104
- }
105
-
106
- clear(): void {
107
- this.logs = [];
108
- }
109
- }
@@ -1,78 +0,0 @@
1
- import type { LexiconDoc } from "@atproto/lexicon";
2
- import type { Session } from "../../src/core/types.js";
3
-
4
- /**
5
- * Create a mock OAuth session for testing
6
- */
7
- export function createMockSession(overrides?: Partial<Session>): Session {
8
- const defaultServerMetadata = {
9
- issuer: "https://pds.example.com",
10
- authorization_endpoint: "https://pds.example.com/oauth/authorize",
11
- token_endpoint: "https://pds.example.com/oauth/token",
12
- token_endpoint_auth_methods_supported: ["private_key_jwt"],
13
- code_challenge_methods_supported: ["S256"],
14
- dpop_signing_alg_values_supported: ["ES256"],
15
- } as const;
16
-
17
- const defaultFetchHandler = async (_url: string, _options?: RequestInit): Promise<Response> => {
18
- // Mock fetch handler - tests will override this
19
- return new Response(JSON.stringify({}), { status: 200 });
20
- };
21
-
22
- const mockSession: Session = {
23
- sub: "did:plc:testdid123456789012345678901234567890",
24
- did: "did:plc:testdid123456789012345678901234567890",
25
- serverMetadata: defaultServerMetadata,
26
- fetchHandler: overrides?.fetchHandler ?? defaultFetchHandler,
27
- getTokenInfo: async () => ({
28
- expiresAt: new Date(Date.now() + 3600 * 1000),
29
- expired: false,
30
- scope: "atproto",
31
- iss: "https://pds.example.com",
32
- aud: "https://example.com/atproto-client-metadata.json",
33
- sub: "did:plc:testdid123456789012345678901234567890",
34
- }),
35
- signOut: async () => {},
36
- ...overrides,
37
- };
38
-
39
- return mockSession;
40
- }
41
-
42
- /**
43
- * Create a mock lexicon document for testing
44
- */
45
- export function createMockLexicon(id: string): LexiconDoc {
46
- return {
47
- lexicon: 1,
48
- id,
49
- defs: {
50
- record: {
51
- type: "record" as const,
52
- record: {
53
- type: "object" as const,
54
- properties: {
55
- text: { type: "string" as const },
56
- },
57
- },
58
- },
59
- },
60
- } as LexiconDoc;
61
- }
62
-
63
- /**
64
- * Create a mock blob reference
65
- */
66
- export function createMockBlobRef(): {
67
- $type: string;
68
- ref: { $link: string };
69
- mimeType: string;
70
- size: number;
71
- } {
72
- return {
73
- $type: "blob",
74
- ref: { $link: "bafyrei..." },
75
- mimeType: "image/png",
76
- size: 1024,
77
- };
78
- }
package/tsconfig.json DELETED
@@ -1,11 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- "compilerOptions": {
4
- "lib": ["ES2020", "DOM"],
5
- "noEmit": false,
6
- "declaration": true,
7
- "declarationMap": true
8
- },
9
- "include": ["src/**/*", "tests/**/*"],
10
- "exclude": ["node_modules", "dist"]
11
- }