@augustdigital/config 0.1.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.
@@ -0,0 +1,265 @@
1
+ import { z } from 'zod';
2
+ export declare const VaultGetSchema: z.ZodObject<{
3
+ address: z.ZodString;
4
+ chainId: z.ZodNumber;
5
+ name: z.ZodOptional<z.ZodString>;
6
+ symbol: z.ZodOptional<z.ZodString>;
7
+ decimals: z.ZodOptional<z.ZodNumber>;
8
+ underlying: z.ZodOptional<z.ZodObject<{
9
+ address: z.ZodOptional<z.ZodString>;
10
+ symbol: z.ZodOptional<z.ZodOptional<z.ZodString>>;
11
+ decimals: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
12
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
13
+ address: z.ZodOptional<z.ZodString>;
14
+ symbol: z.ZodOptional<z.ZodOptional<z.ZodString>>;
15
+ decimals: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
16
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
17
+ address: z.ZodOptional<z.ZodString>;
18
+ symbol: z.ZodOptional<z.ZodOptional<z.ZodString>>;
19
+ decimals: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
20
+ }, z.ZodTypeAny, "passthrough">>>;
21
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
22
+ address: z.ZodString;
23
+ chainId: z.ZodNumber;
24
+ name: z.ZodOptional<z.ZodString>;
25
+ symbol: z.ZodOptional<z.ZodString>;
26
+ decimals: z.ZodOptional<z.ZodNumber>;
27
+ underlying: z.ZodOptional<z.ZodObject<{
28
+ address: z.ZodOptional<z.ZodString>;
29
+ symbol: z.ZodOptional<z.ZodOptional<z.ZodString>>;
30
+ decimals: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
31
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
32
+ address: z.ZodOptional<z.ZodString>;
33
+ symbol: z.ZodOptional<z.ZodOptional<z.ZodString>>;
34
+ decimals: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
35
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
36
+ address: z.ZodOptional<z.ZodString>;
37
+ symbol: z.ZodOptional<z.ZodOptional<z.ZodString>>;
38
+ decimals: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
39
+ }, z.ZodTypeAny, "passthrough">>>;
40
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
41
+ address: z.ZodString;
42
+ chainId: z.ZodNumber;
43
+ name: z.ZodOptional<z.ZodString>;
44
+ symbol: z.ZodOptional<z.ZodString>;
45
+ decimals: z.ZodOptional<z.ZodNumber>;
46
+ underlying: z.ZodOptional<z.ZodObject<{
47
+ address: z.ZodOptional<z.ZodString>;
48
+ symbol: z.ZodOptional<z.ZodOptional<z.ZodString>>;
49
+ decimals: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
50
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
51
+ address: z.ZodOptional<z.ZodString>;
52
+ symbol: z.ZodOptional<z.ZodOptional<z.ZodString>>;
53
+ decimals: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
54
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
55
+ address: z.ZodOptional<z.ZodString>;
56
+ symbol: z.ZodOptional<z.ZodOptional<z.ZodString>>;
57
+ decimals: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
58
+ }, z.ZodTypeAny, "passthrough">>>;
59
+ }, z.ZodTypeAny, "passthrough">>;
60
+ export type VaultGet = z.infer<typeof VaultGetSchema>;
61
+ export declare const VaultApySchema: z.ZodObject<{
62
+ address: z.ZodString;
63
+ chainId: z.ZodNumber;
64
+ currentApy: z.ZodOptional<z.ZodNumber>;
65
+ annualizedApy: z.ZodOptional<z.ZodNumber>;
66
+ asOf: z.ZodOptional<z.ZodString>;
67
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
68
+ address: z.ZodString;
69
+ chainId: z.ZodNumber;
70
+ currentApy: z.ZodOptional<z.ZodNumber>;
71
+ annualizedApy: z.ZodOptional<z.ZodNumber>;
72
+ asOf: z.ZodOptional<z.ZodString>;
73
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
74
+ address: z.ZodString;
75
+ chainId: z.ZodNumber;
76
+ currentApy: z.ZodOptional<z.ZodNumber>;
77
+ annualizedApy: z.ZodOptional<z.ZodNumber>;
78
+ asOf: z.ZodOptional<z.ZodString>;
79
+ }, z.ZodTypeAny, "passthrough">>;
80
+ export type VaultApy = z.infer<typeof VaultApySchema>;
81
+ export declare const VaultTvlSchema: z.ZodObject<{
82
+ address: z.ZodString;
83
+ chainId: z.ZodNumber;
84
+ tvl: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
85
+ underlyingSymbol: z.ZodOptional<z.ZodString>;
86
+ asOf: z.ZodOptional<z.ZodString>;
87
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
88
+ address: z.ZodString;
89
+ chainId: z.ZodNumber;
90
+ tvl: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
91
+ underlyingSymbol: z.ZodOptional<z.ZodString>;
92
+ asOf: z.ZodOptional<z.ZodString>;
93
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
94
+ address: z.ZodString;
95
+ chainId: z.ZodNumber;
96
+ tvl: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
97
+ underlyingSymbol: z.ZodOptional<z.ZodString>;
98
+ asOf: z.ZodOptional<z.ZodString>;
99
+ }, z.ZodTypeAny, "passthrough">>;
100
+ export type VaultTvl = z.infer<typeof VaultTvlSchema>;
101
+ export declare const VaultPositionsSchema: z.ZodObject<{
102
+ address: z.ZodString;
103
+ chainId: z.ZodNumber;
104
+ user: z.ZodOptional<z.ZodString>;
105
+ positions: z.ZodDefault<z.ZodArray<z.ZodObject<{
106
+ user: z.ZodString;
107
+ shares: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
108
+ assets: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
109
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
110
+ user: z.ZodString;
111
+ shares: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
112
+ assets: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
113
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
114
+ user: z.ZodString;
115
+ shares: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
116
+ assets: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
117
+ }, z.ZodTypeAny, "passthrough">>, "many">>;
118
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
119
+ address: z.ZodString;
120
+ chainId: z.ZodNumber;
121
+ user: z.ZodOptional<z.ZodString>;
122
+ positions: z.ZodDefault<z.ZodArray<z.ZodObject<{
123
+ user: z.ZodString;
124
+ shares: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
125
+ assets: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
126
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
127
+ user: z.ZodString;
128
+ shares: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
129
+ assets: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
130
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
131
+ user: z.ZodString;
132
+ shares: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
133
+ assets: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
134
+ }, z.ZodTypeAny, "passthrough">>, "many">>;
135
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
136
+ address: z.ZodString;
137
+ chainId: z.ZodNumber;
138
+ user: z.ZodOptional<z.ZodString>;
139
+ positions: z.ZodDefault<z.ZodArray<z.ZodObject<{
140
+ user: z.ZodString;
141
+ shares: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
142
+ assets: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
143
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
144
+ user: z.ZodString;
145
+ shares: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
146
+ assets: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
147
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
148
+ user: z.ZodString;
149
+ shares: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
150
+ assets: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
151
+ }, z.ZodTypeAny, "passthrough">>, "many">>;
152
+ }, z.ZodTypeAny, "passthrough">>;
153
+ export type VaultPositions = z.infer<typeof VaultPositionsSchema>;
154
+ export declare const VaultLoansSchema: z.ZodObject<{
155
+ address: z.ZodString;
156
+ chainId: z.ZodNumber;
157
+ loans: z.ZodDefault<z.ZodArray<z.ZodUnknown, "many">>;
158
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
159
+ address: z.ZodString;
160
+ chainId: z.ZodNumber;
161
+ loans: z.ZodDefault<z.ZodArray<z.ZodUnknown, "many">>;
162
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
163
+ address: z.ZodString;
164
+ chainId: z.ZodNumber;
165
+ loans: z.ZodDefault<z.ZodArray<z.ZodUnknown, "many">>;
166
+ }, z.ZodTypeAny, "passthrough">>;
167
+ export type VaultLoans = z.infer<typeof VaultLoansSchema>;
168
+ export declare const VaultAllocationsSchema: z.ZodObject<{
169
+ address: z.ZodString;
170
+ chainId: z.ZodNumber;
171
+ allocations: z.ZodDefault<z.ZodArray<z.ZodUnknown, "many">>;
172
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
173
+ address: z.ZodString;
174
+ chainId: z.ZodNumber;
175
+ allocations: z.ZodDefault<z.ZodArray<z.ZodUnknown, "many">>;
176
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
177
+ address: z.ZodString;
178
+ chainId: z.ZodNumber;
179
+ allocations: z.ZodDefault<z.ZodArray<z.ZodUnknown, "many">>;
180
+ }, z.ZodTypeAny, "passthrough">>;
181
+ export type VaultAllocations = z.infer<typeof VaultAllocationsSchema>;
182
+ export declare const VaultRedemptionsSchema: z.ZodObject<{
183
+ address: z.ZodString;
184
+ chainId: z.ZodNumber;
185
+ user: z.ZodOptional<z.ZodString>;
186
+ available: z.ZodDefault<z.ZodArray<z.ZodUnknown, "many">>;
187
+ history: z.ZodDefault<z.ZodArray<z.ZodUnknown, "many">>;
188
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
189
+ address: z.ZodString;
190
+ chainId: z.ZodNumber;
191
+ user: z.ZodOptional<z.ZodString>;
192
+ available: z.ZodDefault<z.ZodArray<z.ZodUnknown, "many">>;
193
+ history: z.ZodDefault<z.ZodArray<z.ZodUnknown, "many">>;
194
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
195
+ address: z.ZodString;
196
+ chainId: z.ZodNumber;
197
+ user: z.ZodOptional<z.ZodString>;
198
+ available: z.ZodDefault<z.ZodArray<z.ZodUnknown, "many">>;
199
+ history: z.ZodDefault<z.ZodArray<z.ZodUnknown, "many">>;
200
+ }, z.ZodTypeAny, "passthrough">>;
201
+ export type VaultRedemptions = z.infer<typeof VaultRedemptionsSchema>;
202
+ export declare const VaultHistorySchema: z.ZodObject<{
203
+ address: z.ZodString;
204
+ chainId: z.ZodNumber;
205
+ from: z.ZodOptional<z.ZodString>;
206
+ to: z.ZodOptional<z.ZodString>;
207
+ series: z.ZodDefault<z.ZodArray<z.ZodUnknown, "many">>;
208
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
209
+ address: z.ZodString;
210
+ chainId: z.ZodNumber;
211
+ from: z.ZodOptional<z.ZodString>;
212
+ to: z.ZodOptional<z.ZodString>;
213
+ series: z.ZodDefault<z.ZodArray<z.ZodUnknown, "many">>;
214
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
215
+ address: z.ZodString;
216
+ chainId: z.ZodNumber;
217
+ from: z.ZodOptional<z.ZodString>;
218
+ to: z.ZodOptional<z.ZodString>;
219
+ series: z.ZodDefault<z.ZodArray<z.ZodUnknown, "many">>;
220
+ }, z.ZodTypeAny, "passthrough">>;
221
+ export type VaultHistory = z.infer<typeof VaultHistorySchema>;
222
+ export declare const VaultSummarySchema: z.ZodObject<{
223
+ address: z.ZodString;
224
+ chainId: z.ZodNumber;
225
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
226
+ address: z.ZodString;
227
+ chainId: z.ZodNumber;
228
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
229
+ address: z.ZodString;
230
+ chainId: z.ZodNumber;
231
+ }, z.ZodTypeAny, "passthrough">>;
232
+ export type VaultSummary = z.infer<typeof VaultSummarySchema>;
233
+ export declare const VaultListSchema: z.ZodObject<{
234
+ vaults: z.ZodArray<z.ZodObject<{
235
+ name: z.ZodString;
236
+ symbol: z.ZodString;
237
+ address: z.ZodString;
238
+ chainId: z.ZodOptional<z.ZodNumber>;
239
+ }, "strip", z.ZodTypeAny, {
240
+ symbol?: string;
241
+ name?: string;
242
+ chainId?: number;
243
+ address?: string;
244
+ }, {
245
+ symbol?: string;
246
+ name?: string;
247
+ chainId?: number;
248
+ address?: string;
249
+ }>, "many">;
250
+ }, "strip", z.ZodTypeAny, {
251
+ vaults?: {
252
+ symbol?: string;
253
+ name?: string;
254
+ chainId?: number;
255
+ address?: string;
256
+ }[];
257
+ }, {
258
+ vaults?: {
259
+ symbol?: string;
260
+ name?: string;
261
+ chainId?: number;
262
+ address?: string;
263
+ }[];
264
+ }>;
265
+ export type VaultList = z.infer<typeof VaultListSchema>;
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VaultListSchema = exports.VaultSummarySchema = exports.VaultHistorySchema = exports.VaultRedemptionsSchema = exports.VaultAllocationsSchema = exports.VaultLoansSchema = exports.VaultPositionsSchema = exports.VaultTvlSchema = exports.VaultApySchema = exports.VaultGetSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const Address = zod_1.z
6
+ .string()
7
+ .regex(/^(0x[0-9a-fA-F]{40}|[1-9A-HJ-NP-Za-km-z]{32,44})$/, {
8
+ message: 'Expected an EVM (0x…) or Solana address.',
9
+ });
10
+ const BigNumeric = zod_1.z.union([zod_1.z.string(), zod_1.z.number()]);
11
+ exports.VaultGetSchema = zod_1.z
12
+ .object({
13
+ address: Address,
14
+ chainId: zod_1.z.number().int(),
15
+ name: zod_1.z.string().optional(),
16
+ symbol: zod_1.z.string().optional(),
17
+ decimals: zod_1.z.number().int().nonnegative().optional(),
18
+ underlying: zod_1.z
19
+ .object({
20
+ address: Address,
21
+ symbol: zod_1.z.string().optional(),
22
+ decimals: zod_1.z.number().int().nonnegative().optional(),
23
+ })
24
+ .partial()
25
+ .passthrough()
26
+ .optional(),
27
+ })
28
+ .passthrough();
29
+ exports.VaultApySchema = zod_1.z
30
+ .object({
31
+ address: Address,
32
+ chainId: zod_1.z.number().int(),
33
+ currentApy: zod_1.z.number().optional(),
34
+ annualizedApy: zod_1.z.number().optional(),
35
+ asOf: zod_1.z.string().datetime().optional(),
36
+ })
37
+ .passthrough();
38
+ exports.VaultTvlSchema = zod_1.z
39
+ .object({
40
+ address: Address,
41
+ chainId: zod_1.z.number().int(),
42
+ tvl: BigNumeric,
43
+ underlyingSymbol: zod_1.z.string().optional(),
44
+ asOf: zod_1.z.string().datetime().optional(),
45
+ })
46
+ .passthrough();
47
+ exports.VaultPositionsSchema = zod_1.z
48
+ .object({
49
+ address: Address,
50
+ chainId: zod_1.z.number().int(),
51
+ user: Address.optional(),
52
+ positions: zod_1.z
53
+ .array(zod_1.z
54
+ .object({
55
+ user: Address,
56
+ shares: BigNumeric,
57
+ assets: BigNumeric.optional(),
58
+ })
59
+ .passthrough())
60
+ .default([]),
61
+ })
62
+ .passthrough();
63
+ exports.VaultLoansSchema = zod_1.z
64
+ .object({
65
+ address: Address,
66
+ chainId: zod_1.z.number().int(),
67
+ loans: zod_1.z.array(zod_1.z.unknown()).default([]),
68
+ })
69
+ .passthrough();
70
+ exports.VaultAllocationsSchema = zod_1.z
71
+ .object({
72
+ address: Address,
73
+ chainId: zod_1.z.number().int(),
74
+ allocations: zod_1.z.array(zod_1.z.unknown()).default([]),
75
+ })
76
+ .passthrough();
77
+ exports.VaultRedemptionsSchema = zod_1.z
78
+ .object({
79
+ address: Address,
80
+ chainId: zod_1.z.number().int(),
81
+ user: Address.optional(),
82
+ available: zod_1.z.array(zod_1.z.unknown()).default([]),
83
+ history: zod_1.z.array(zod_1.z.unknown()).default([]),
84
+ })
85
+ .passthrough();
86
+ exports.VaultHistorySchema = zod_1.z
87
+ .object({
88
+ address: Address,
89
+ chainId: zod_1.z.number().int(),
90
+ from: zod_1.z.string().datetime().optional(),
91
+ to: zod_1.z.string().datetime().optional(),
92
+ series: zod_1.z.array(zod_1.z.unknown()).default([]),
93
+ })
94
+ .passthrough();
95
+ exports.VaultSummarySchema = zod_1.z
96
+ .object({
97
+ address: Address,
98
+ chainId: zod_1.z.number().int(),
99
+ })
100
+ .passthrough();
101
+ exports.VaultListSchema = zod_1.z.object({
102
+ vaults: zod_1.z.array(zod_1.z.object({
103
+ name: zod_1.z.string(),
104
+ symbol: zod_1.z.string(),
105
+ address: Address,
106
+ chainId: zod_1.z.number().int().optional(),
107
+ })),
108
+ });
109
+ //# sourceMappingURL=vault.js.map
package/lib/sdk.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ import AugustSDK from '@augustdigital/sdk';
2
+ import { Config } from './config';
3
+ export interface CreateSdkOptions {
4
+ config?: Config;
5
+ profileName?: string;
6
+ appName?: string;
7
+ withoutApiKey?: boolean;
8
+ cliApiKey?: string;
9
+ chainId?: number;
10
+ cliRpcUrl?: string;
11
+ disableAnalytics?: boolean;
12
+ }
13
+ export declare function createSDK(opts?: CreateSdkOptions): Promise<AugustSDK>;
14
+ export declare function resolvedRpcUrl(chainId: number): string;
package/lib/sdk.js ADDED
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.createSDK = createSDK;
37
+ exports.resolvedRpcUrl = resolvedRpcUrl;
38
+ const sdk_1 = __importStar(require("@augustdigital/sdk"));
39
+ const config_1 = require("./config");
40
+ const profile_1 = require("./profile");
41
+ const precedence_1 = require("./precedence");
42
+ function buildProviders(config, profileRpcs, chainId, cliRpcUrl) {
43
+ const merged = {
44
+ ...config.rpcs,
45
+ ...(profileRpcs ?? {}),
46
+ };
47
+ for (const key of Object.keys(process.env)) {
48
+ if (key.startsWith('AUGUST_RPC_')) {
49
+ const tail = key.slice('AUGUST_RPC_'.length);
50
+ if (/^\d+$/.test(tail)) {
51
+ const url = process.env[key]?.trim();
52
+ if (url)
53
+ merged[tail] = url;
54
+ }
55
+ }
56
+ }
57
+ if (chainId !== undefined && cliRpcUrl) {
58
+ merged[String(chainId)] = cliRpcUrl;
59
+ }
60
+ const out = {};
61
+ for (const [k, v] of Object.entries(merged)) {
62
+ const n = Number(k);
63
+ if (Number.isFinite(n))
64
+ out[n] = v;
65
+ }
66
+ if (chainId !== undefined && out[chainId] === undefined) {
67
+ const [publicFallback] = (0, sdk_1.getFallbackRpcUrls)(chainId);
68
+ if (publicFallback)
69
+ out[chainId] = publicFallback;
70
+ }
71
+ return out;
72
+ }
73
+ async function createSDK(opts = {}) {
74
+ const config = opts.config ?? (0, config_1.loadConfig)();
75
+ const profileName = opts.profileName ?? process.env.AUGUST_PROFILE ?? config.defaultProfile;
76
+ let profileRpcs;
77
+ try {
78
+ profileRpcs = (0, profile_1.loadProfile)(profileName).rpcs;
79
+ }
80
+ catch {
81
+ profileRpcs = undefined;
82
+ }
83
+ const providers = buildProviders(config, profileRpcs, opts.chainId, opts.cliRpcUrl);
84
+ const augustKey = opts.withoutApiKey
85
+ ? undefined
86
+ : tryGetApiKey({ cliApiKey: opts.cliApiKey, profileName });
87
+ const appName = opts.appName ?? config.appName ?? 'august-cli';
88
+ const disableAnalytics = opts.disableAnalytics !== undefined
89
+ ? opts.disableAnalytics
90
+ : !config.telemetry;
91
+ if (opts.chainId !== undefined && opts.cliRpcUrl) {
92
+ return new sdk_1.default({
93
+ appName,
94
+ providers: { [opts.chainId]: opts.cliRpcUrl, ...providers },
95
+ keys: augustKey ? { august: augustKey } : {},
96
+ analytics: { enabled: !disableAnalytics },
97
+ });
98
+ }
99
+ return new sdk_1.default({
100
+ appName,
101
+ providers,
102
+ keys: augustKey ? { august: augustKey } : {},
103
+ analytics: { enabled: !disableAnalytics },
104
+ });
105
+ }
106
+ function tryGetApiKey(opts) {
107
+ try {
108
+ return (0, precedence_1.getApiKey)({
109
+ cliApiKey: opts.cliApiKey,
110
+ profileName: opts.profileName,
111
+ });
112
+ }
113
+ catch {
114
+ return undefined;
115
+ }
116
+ }
117
+ function resolvedRpcUrl(chainId) {
118
+ return (0, precedence_1.getRpcUrl)(chainId);
119
+ }
120
+ //# sourceMappingURL=sdk.js.map
@@ -0,0 +1,8 @@
1
+ export interface SessionPayload {
2
+ apiKey?: string;
3
+ expiresAt: number;
4
+ }
5
+ export declare function readSession(path?: string): SessionPayload | null;
6
+ export declare function writeSession(payload: Omit<SessionPayload, 'expiresAt'>, ttlSec: number, path?: string): SessionPayload;
7
+ export declare function clearSession(path?: string): void;
8
+ export declare function sessionActive(path?: string): boolean;
package/lib/session.js ADDED
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readSession = readSession;
4
+ exports.writeSession = writeSession;
5
+ exports.clearSession = clearSession;
6
+ exports.sessionActive = sessionActive;
7
+ const node_fs_1 = require("node:fs");
8
+ const node_path_1 = require("node:path");
9
+ const zod_1 = require("zod");
10
+ const errors_1 = require("./errors");
11
+ const paths_1 = require("./paths");
12
+ const SessionFileSchema = zod_1.z.object({
13
+ schemaVersion: zod_1.z.literal(1),
14
+ apiKey: zod_1.z.string().min(1).optional(),
15
+ expiresAt: zod_1.z.number().int().positive(),
16
+ });
17
+ function ensureFileMode(path, mode) {
18
+ try {
19
+ (0, node_fs_1.chmodSync)(path, mode);
20
+ }
21
+ catch {
22
+ }
23
+ }
24
+ function readSession(path = (0, paths_1.sessionFile)()) {
25
+ if (!(0, node_fs_1.existsSync)(path))
26
+ return null;
27
+ let raw;
28
+ try {
29
+ raw = JSON.parse((0, node_fs_1.readFileSync)(path, 'utf8'));
30
+ }
31
+ catch {
32
+ throw new errors_1.AugustConfigError('SESSION_INVALID', `Session file at ${path} is not valid JSON.`, 'Run `august logout` and then `august login` again.');
33
+ }
34
+ const parsed = SessionFileSchema.safeParse(raw);
35
+ if (!parsed.success) {
36
+ throw new errors_1.AugustConfigError('SESSION_INVALID', `Session file at ${path} failed validation.`, 'Run `august logout` and then `august login` again.');
37
+ }
38
+ if (parsed.data.expiresAt <= Date.now()) {
39
+ throw new errors_1.AugustConfigError('SESSION_EXPIRED', 'Session has expired.', 'Run `august login` to start a new session.');
40
+ }
41
+ return {
42
+ apiKey: parsed.data.apiKey,
43
+ expiresAt: parsed.data.expiresAt,
44
+ };
45
+ }
46
+ function writeSession(payload, ttlSec, path = (0, paths_1.sessionFile)()) {
47
+ if (!Number.isFinite(ttlSec) || ttlSec <= 0) {
48
+ throw new errors_1.AugustConfigError('SESSION_INVALID', `Session TTL must be a positive number of seconds (got ${ttlSec}).`);
49
+ }
50
+ const expiresAt = Date.now() + ttlSec * 1000;
51
+ const file = { schemaVersion: 1, ...payload, expiresAt };
52
+ const dir = (0, node_path_1.dirname)(path);
53
+ if (!(0, node_fs_1.existsSync)(dir)) {
54
+ (0, node_fs_1.mkdirSync)(dir, { recursive: true, mode: 0o700 });
55
+ }
56
+ (0, node_fs_1.writeFileSync)(path, JSON.stringify(file, null, 2), {
57
+ encoding: 'utf8',
58
+ mode: 0o600,
59
+ });
60
+ ensureFileMode(path, 0o600);
61
+ ensureFileMode(dir, 0o700);
62
+ return { apiKey: payload.apiKey, expiresAt };
63
+ }
64
+ function clearSession(path = (0, paths_1.sessionFile)()) {
65
+ if ((0, node_fs_1.existsSync)(path))
66
+ (0, node_fs_1.unlinkSync)(path);
67
+ }
68
+ function sessionActive(path = (0, paths_1.sessionFile)()) {
69
+ try {
70
+ return readSession(path) !== null;
71
+ }
72
+ catch {
73
+ return false;
74
+ }
75
+ }
76
+ //# sourceMappingURL=session.js.map
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@augustdigital/config",
3
+ "version": "0.1.0",
4
+ "main": "lib/index.js",
5
+ "types": "lib/index.d.ts",
6
+ "description": "Shared configuration, keystore, and SDK factory used by @augustdigital/cli and @augustdigital/mcp.",
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
10
+ "keywords": [
11
+ "augustdigital",
12
+ "sdk",
13
+ "cli",
14
+ "mcp",
15
+ "config"
16
+ ],
17
+ "author": "August Digital",
18
+ "license": "MIT",
19
+ "lint-staged": {
20
+ "*.{ts,tsx,js,jsx,json}": [
21
+ "eslint --fix"
22
+ ],
23
+ "*.{md,html,yaml}": [
24
+ "prettier --write"
25
+ ]
26
+ },
27
+ "files": [
28
+ "lib/**/*.js",
29
+ "lib/**/*.d.ts",
30
+ "lib/**/*.json"
31
+ ],
32
+ "dependencies": {
33
+ "zod": "^3.23.0",
34
+ "@augustdigital/sdk": "4.27.3"
35
+ },
36
+ "devDependencies": {
37
+ "@types/jest": "^29.5.0",
38
+ "@types/node": "^20.14.9",
39
+ "jest": "^29.7.0",
40
+ "ts-jest": "^29.1.0",
41
+ "typescript": "^5.9.2"
42
+ },
43
+ "scripts": {
44
+ "build": "tsc",
45
+ "clean": "rm -rf ./lib",
46
+ "test": "jest",
47
+ "test:watch": "jest --watch",
48
+ "format": "eslint . --fix",
49
+ "lint-config": "lint-staged"
50
+ }
51
+ }