@hearth-auth/sdk 0.0.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +680 -0
  3. package/package.json +44 -0
  4. package/src/admin.ts +157 -0
  5. package/src/browser-auth.ts +130 -0
  6. package/src/claims.ts +180 -0
  7. package/src/client.ts +251 -0
  8. package/src/errors.ts +173 -0
  9. package/src/generated/google/api/annotations_pb.ts +44 -0
  10. package/src/generated/google/api/http_pb.ts +467 -0
  11. package/src/generated/hearth/authz/v1/authz_pb.ts +593 -0
  12. package/src/generated/hearth/cluster/v1/raft_pb.ts +183 -0
  13. package/src/generated/hearth/events/v1/audit_pb.ts +886 -0
  14. package/src/generated/hearth/identity/v1/identity_pb.ts +1673 -0
  15. package/src/generated/hearth/identity/v1/oauth_pb.ts +1138 -0
  16. package/src/generated/hearth/rbac/v1/rbac_pb.ts +2000 -0
  17. package/src/hearth-client.ts +288 -0
  18. package/src/hearth.ts +224 -0
  19. package/src/index.ts +106 -0
  20. package/src/introspection-client.ts +83 -0
  21. package/src/jwks-client.ts +45 -0
  22. package/src/middleware.ts +82 -0
  23. package/src/pkce.ts +129 -0
  24. package/src/react.tsx +57 -0
  25. package/src/session-version-cache.ts +167 -0
  26. package/src/types.ts +188 -0
  27. package/tests/admin-crud.test.ts +97 -0
  28. package/tests/auth-flow.test.ts +75 -0
  29. package/tests/authorize.test.ts +386 -0
  30. package/tests/claims.test.ts +159 -0
  31. package/tests/hasPermission.test.ts +152 -0
  32. package/tests/hearth-client.test.ts +243 -0
  33. package/tests/helpers.ts +90 -0
  34. package/tests/jwks.test.ts +62 -0
  35. package/tests/pkce.test.ts +210 -0
  36. package/tests/react-useHasPermission.test.tsx +92 -0
  37. package/tests/required-action.test.ts +276 -0
  38. package/tests/session-version.test.ts +391 -0
  39. package/tsconfig.json +16 -0
  40. package/vitest.config.ts +8 -0
@@ -0,0 +1,183 @@
1
+ // @generated by protoc-gen-es v2.12.0 with parameter "target=ts"
2
+ // @generated from file hearth/cluster/v1/raft.proto (package hearth.cluster.v1, syntax proto3)
3
+ /* eslint-disable */
4
+
5
+ import type { GenFile, GenMessage, GenService } from "@bufbuild/protobuf/codegenv2";
6
+ import { fileDesc, messageDesc, serviceDesc } from "@bufbuild/protobuf/codegenv2";
7
+ import type { Message } from "@bufbuild/protobuf";
8
+
9
+ /**
10
+ * Describes the file hearth/cluster/v1/raft.proto.
11
+ */
12
+ export const file_hearth_cluster_v1_raft: GenFile = /*@__PURE__*/
13
+ fileDesc("ChxoZWFydGgvY2x1c3Rlci92MS9yYWZ0LnByb3RvEhFoZWFydGguY2x1c3Rlci52MSInChRBcHBlbmRFbnRyaWVzUmVxdWVzdBIPCgdwYXlsb2FkGAEgASgMIigKFUFwcGVuZEVudHJpZXNSZXNwb25zZRIPCgdwYXlsb2FkGAEgASgMIh4KC1ZvdGVSZXF1ZXN0Eg8KB3BheWxvYWQYASABKAwiHwoMVm90ZVJlc3BvbnNlEg8KB3BheWxvYWQYASABKAwiKQoWSW5zdGFsbFNuYXBzaG90UmVxdWVzdBIPCgdwYXlsb2FkGAEgASgMIioKF0luc3RhbGxTbmFwc2hvdFJlc3BvbnNlEg8KB3BheWxvYWQYASABKAwypAIKC1JhZnRTZXJ2aWNlEmIKDUFwcGVuZEVudHJpZXMSJy5oZWFydGguY2x1c3Rlci52MS5BcHBlbmRFbnRyaWVzUmVxdWVzdBooLmhlYXJ0aC5jbHVzdGVyLnYxLkFwcGVuZEVudHJpZXNSZXNwb25zZRJHCgRWb3RlEh4uaGVhcnRoLmNsdXN0ZXIudjEuVm90ZVJlcXVlc3QaHy5oZWFydGguY2x1c3Rlci52MS5Wb3RlUmVzcG9uc2USaAoPSW5zdGFsbFNuYXBzaG90EikuaGVhcnRoLmNsdXN0ZXIudjEuSW5zdGFsbFNuYXBzaG90UmVxdWVzdBoqLmhlYXJ0aC5jbHVzdGVyLnYxLkluc3RhbGxTbmFwc2hvdFJlc3BvbnNlQkNaQWdpdGh1Yi5jb20vaGVhcnRoZGIvaGVhcnRoL3Nka3MvZ28vZ2VuZXJhdGVkL2NsdXN0ZXIvdjE7Y2x1c3RlcnYxYgZwcm90bzM");
14
+
15
+ /**
16
+ * AppendEntries RPC request.
17
+ * Payload is serde_json-encoded openraft::AppendEntriesRequest<HearthRaftConfig>.
18
+ *
19
+ * @generated from message hearth.cluster.v1.AppendEntriesRequest
20
+ */
21
+ export type AppendEntriesRequest = Message<"hearth.cluster.v1.AppendEntriesRequest"> & {
22
+ /**
23
+ * @generated from field: bytes payload = 1;
24
+ */
25
+ payload: Uint8Array;
26
+ };
27
+
28
+ /**
29
+ * Describes the message hearth.cluster.v1.AppendEntriesRequest.
30
+ * Use `create(AppendEntriesRequestSchema)` to create a new message.
31
+ */
32
+ export const AppendEntriesRequestSchema: GenMessage<AppendEntriesRequest> = /*@__PURE__*/
33
+ messageDesc(file_hearth_cluster_v1_raft, 0);
34
+
35
+ /**
36
+ * AppendEntries RPC response.
37
+ * Payload is serde_json-encoded openraft::AppendEntriesResponse<u64>.
38
+ *
39
+ * @generated from message hearth.cluster.v1.AppendEntriesResponse
40
+ */
41
+ export type AppendEntriesResponse = Message<"hearth.cluster.v1.AppendEntriesResponse"> & {
42
+ /**
43
+ * @generated from field: bytes payload = 1;
44
+ */
45
+ payload: Uint8Array;
46
+ };
47
+
48
+ /**
49
+ * Describes the message hearth.cluster.v1.AppendEntriesResponse.
50
+ * Use `create(AppendEntriesResponseSchema)` to create a new message.
51
+ */
52
+ export const AppendEntriesResponseSchema: GenMessage<AppendEntriesResponse> = /*@__PURE__*/
53
+ messageDesc(file_hearth_cluster_v1_raft, 1);
54
+
55
+ /**
56
+ * Vote RPC request.
57
+ * Payload is serde_json-encoded openraft::VoteRequest<u64>.
58
+ *
59
+ * @generated from message hearth.cluster.v1.VoteRequest
60
+ */
61
+ export type VoteRequest = Message<"hearth.cluster.v1.VoteRequest"> & {
62
+ /**
63
+ * @generated from field: bytes payload = 1;
64
+ */
65
+ payload: Uint8Array;
66
+ };
67
+
68
+ /**
69
+ * Describes the message hearth.cluster.v1.VoteRequest.
70
+ * Use `create(VoteRequestSchema)` to create a new message.
71
+ */
72
+ export const VoteRequestSchema: GenMessage<VoteRequest> = /*@__PURE__*/
73
+ messageDesc(file_hearth_cluster_v1_raft, 2);
74
+
75
+ /**
76
+ * Vote RPC response.
77
+ * Payload is serde_json-encoded openraft::VoteResponse<u64>.
78
+ *
79
+ * @generated from message hearth.cluster.v1.VoteResponse
80
+ */
81
+ export type VoteResponse = Message<"hearth.cluster.v1.VoteResponse"> & {
82
+ /**
83
+ * @generated from field: bytes payload = 1;
84
+ */
85
+ payload: Uint8Array;
86
+ };
87
+
88
+ /**
89
+ * Describes the message hearth.cluster.v1.VoteResponse.
90
+ * Use `create(VoteResponseSchema)` to create a new message.
91
+ */
92
+ export const VoteResponseSchema: GenMessage<VoteResponse> = /*@__PURE__*/
93
+ messageDesc(file_hearth_cluster_v1_raft, 3);
94
+
95
+ /**
96
+ * InstallSnapshot RPC request (one chunk per call).
97
+ * Payload is serde_json-encoded openraft::InstallSnapshotRequest<HearthRaftConfig>.
98
+ *
99
+ * @generated from message hearth.cluster.v1.InstallSnapshotRequest
100
+ */
101
+ export type InstallSnapshotRequest = Message<"hearth.cluster.v1.InstallSnapshotRequest"> & {
102
+ /**
103
+ * @generated from field: bytes payload = 1;
104
+ */
105
+ payload: Uint8Array;
106
+ };
107
+
108
+ /**
109
+ * Describes the message hearth.cluster.v1.InstallSnapshotRequest.
110
+ * Use `create(InstallSnapshotRequestSchema)` to create a new message.
111
+ */
112
+ export const InstallSnapshotRequestSchema: GenMessage<InstallSnapshotRequest> = /*@__PURE__*/
113
+ messageDesc(file_hearth_cluster_v1_raft, 4);
114
+
115
+ /**
116
+ * InstallSnapshot RPC response.
117
+ * Payload is serde_json-encoded openraft::InstallSnapshotResponse<u64>.
118
+ *
119
+ * @generated from message hearth.cluster.v1.InstallSnapshotResponse
120
+ */
121
+ export type InstallSnapshotResponse = Message<"hearth.cluster.v1.InstallSnapshotResponse"> & {
122
+ /**
123
+ * @generated from field: bytes payload = 1;
124
+ */
125
+ payload: Uint8Array;
126
+ };
127
+
128
+ /**
129
+ * Describes the message hearth.cluster.v1.InstallSnapshotResponse.
130
+ * Use `create(InstallSnapshotResponseSchema)` to create a new message.
131
+ */
132
+ export const InstallSnapshotResponseSchema: GenMessage<InstallSnapshotResponse> = /*@__PURE__*/
133
+ messageDesc(file_hearth_cluster_v1_raft, 5);
134
+
135
+ /**
136
+ * Raft consensus peer-to-peer RPC service.
137
+ *
138
+ * All messages carry opaque JSON-encoded payloads to decouple the transport
139
+ * schema from openraft's internal types. This keeps the wire format stable
140
+ * across openraft version upgrades.
141
+ *
142
+ * InstallSnapshot is a unary RPC: openraft's default full_snapshot
143
+ * implementation already chunks the snapshot and calls install_snapshot once
144
+ * per chunk (with offset/done fields inside the payload), so there is no need
145
+ * for a streaming RPC at this layer.
146
+ *
147
+ * @generated from service hearth.cluster.v1.RaftService
148
+ */
149
+ export const RaftService: GenService<{
150
+ /**
151
+ * Leader replicates log entries to a follower or candidate.
152
+ *
153
+ * @generated from rpc hearth.cluster.v1.RaftService.AppendEntries
154
+ */
155
+ appendEntries: {
156
+ methodKind: "unary";
157
+ input: typeof AppendEntriesRequestSchema;
158
+ output: typeof AppendEntriesResponseSchema;
159
+ },
160
+ /**
161
+ * Candidate requests a vote from a peer during leader election.
162
+ *
163
+ * @generated from rpc hearth.cluster.v1.RaftService.Vote
164
+ */
165
+ vote: {
166
+ methodKind: "unary";
167
+ input: typeof VoteRequestSchema;
168
+ output: typeof VoteResponseSchema;
169
+ },
170
+ /**
171
+ * Leader sends one snapshot chunk to a follower.
172
+ * Called once per chunk by openraft's Chunked snapshot transport.
173
+ *
174
+ * @generated from rpc hearth.cluster.v1.RaftService.InstallSnapshot
175
+ */
176
+ installSnapshot: {
177
+ methodKind: "unary";
178
+ input: typeof InstallSnapshotRequestSchema;
179
+ output: typeof InstallSnapshotResponseSchema;
180
+ },
181
+ }> = /*@__PURE__*/
182
+ serviceDesc(file_hearth_cluster_v1_raft, 0);
183
+