@distilled.cloud/coinbase 1.0.0-rc.1 → 1.0.0-rc.3

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,33 @@
1
+ import * as Context from "effect/Context";
2
+ import * as Effect from "effect/Effect";
3
+ import * as Layer from "effect/Layer";
4
+ import * as Redacted from "effect/Redacted";
5
+ export declare const DEFAULT_API_BASE_URL = "https://api.cdp.coinbase.com/platform";
6
+ export interface Config {
7
+ /**
8
+ * CDP API Key ID (UUID format or legacy `organizations/.../apiKeys/...` format).
9
+ */
10
+ readonly apiKeyId: string;
11
+ /**
12
+ * CDP API Key Secret (Ed25519 base64 or EC PEM private key).
13
+ * Used to sign JWT bearer tokens for API authentication.
14
+ */
15
+ readonly apiKeySecret: Redacted.Redacted<string>;
16
+ /**
17
+ * CDP Wallet Secret (base64-encoded DER EC private key).
18
+ * Required only for sensitive wallet operations (POST/DELETE/PUT to account endpoints).
19
+ * If not provided, wallet-auth-requiring operations will fail.
20
+ */
21
+ readonly walletSecret?: Redacted.Redacted<string> | undefined;
22
+ /**
23
+ * Base URL for the Coinbase CDP API.
24
+ * @default "https://api.cdp.coinbase.com/platform"
25
+ */
26
+ readonly apiBaseUrl: string;
27
+ }
28
+ declare const Credentials_base: Context.ServiceClass<Credentials, "CoinbaseCredentials", Effect.Effect<Config, never, never>>;
29
+ export declare class Credentials extends Credentials_base {
30
+ }
31
+ export declare const CredentialsFromEnv: Layer.Layer<Credentials, never, never>;
32
+ export {};
33
+ //# sourceMappingURL=credentials.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAE5C,eAAO,MAAM,oBAAoB,0CAA0C,CAAC;AAE5E,MAAM,WAAW,MAAM;IACrB;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B;;;OAGG;IACH,QAAQ,CAAC,YAAY,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAEjD;;;;OAIG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;IAE9D;;;OAGG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;;AAED,qBAAa,WAAY,SAAQ,gBAGP;CAAG;AAS7B,eAAO,MAAM,kBAAkB,wCAgC9B,CAAC"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Coinbase CDP credentials — hand-written.
3
+ *
4
+ * API-compatible port of the distilled repo's coinbase credentials module:
5
+ * the `Credentials` service holds an *effect* that resolves the current
6
+ * credentials on every request. The protocol layer resolves it per request
7
+ * and signs a fresh JWT bearer token from the API Key Secret.
8
+ */
9
+ import { ConfigError } from "@distilled.cloud/core/errors";
10
+ import * as EffectConfig from "effect/Config";
11
+ import * as Context from "effect/Context";
12
+ import * as Effect from "effect/Effect";
13
+ import * as Layer from "effect/Layer";
14
+ import * as Option from "effect/Option";
15
+ import * as Redacted from "effect/Redacted";
16
+ export const DEFAULT_API_BASE_URL = "https://api.cdp.coinbase.com/platform";
17
+ export class Credentials extends Context.Service()("CoinbaseCredentials") {
18
+ }
19
+ const envConfig = EffectConfig.all({
20
+ apiKeyId: EffectConfig.option(EffectConfig.string("CDP_API_KEY_ID")),
21
+ apiKeyName: EffectConfig.option(EffectConfig.string("CDP_API_KEY_NAME")),
22
+ apiKeySecret: EffectConfig.string("CDP_API_KEY_SECRET"),
23
+ walletSecret: EffectConfig.option(EffectConfig.string("CDP_WALLET_SECRET")),
24
+ });
25
+ export const CredentialsFromEnv = Layer.succeed(Credentials, Effect.gen(function* () {
26
+ const config = yield* envConfig.pipe(Effect.mapError(() => new ConfigError({
27
+ message: "CDP_API_KEY_SECRET environment variable is required",
28
+ })));
29
+ const apiKeyId = Option.getOrUndefined(config.apiKeyId) ??
30
+ Option.getOrUndefined(config.apiKeyName);
31
+ if (!apiKeyId) {
32
+ return yield* new ConfigError({
33
+ message: "CDP_API_KEY_ID (or CDP_API_KEY_NAME) environment variable is required",
34
+ });
35
+ }
36
+ const walletSecret = Option.getOrUndefined(config.walletSecret);
37
+ return {
38
+ apiKeyId,
39
+ apiKeySecret: Redacted.make(config.apiKeySecret),
40
+ walletSecret: walletSecret ? Redacted.make(walletSecret) : undefined,
41
+ apiBaseUrl: DEFAULT_API_BASE_URL,
42
+ };
43
+ }).pipe(Effect.orDie));
44
+ //# sourceMappingURL=credentials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentials.js","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,KAAK,YAAY,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAE5C,MAAM,CAAC,MAAM,oBAAoB,GAAG,uCAAuC,CAAC;AA4B5E,MAAM,OAAO,WAAY,SAAQ,OAAO,CAAC,OAAO,EAG7C,CAAC,qBAAqB,CAAC;CAAG;AAE7B,MAAM,SAAS,GAAG,YAAY,CAAC,GAAG,CAAC;IACjC,QAAQ,EAAE,YAAY,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;IACpE,UAAU,EAAE,YAAY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