@tillstack/secrets-edge 0.2.1 → 0.3.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.
package/dist/index.d.mts CHANGED
@@ -1,8 +1,25 @@
1
- import { SecretsClientOptions, SecretsClient } from '@tillstack/secrets-core';
1
+ import { BrokerClient, SecretsClientOptions, SecretsClient } from '@tillstack/secrets-core';
2
2
  export * from '@tillstack/secrets-core';
3
3
 
4
4
  /** Create a TillSecrets client. Pass an explicit `fetch` if the runtime has no
5
5
  * global one. */
6
6
  declare function createClient(opts: SecretsClientOptions): SecretsClient;
7
+ interface CreateEdgeBrokerOptions {
8
+ /** Cloud API base (derives the spend endpoint) — or pass `endpoint` directly. */
9
+ url?: string;
10
+ /** Full spend endpoint; overrides `url`. */
11
+ endpoint?: string;
12
+ /** Bearer token — a session / `tp_` API key (NOT the `ts_` service token). */
13
+ token: string;
14
+ /** Stable agent identity — required by the cloud broker. */
15
+ agentKey: string;
16
+ sessionId?: string;
17
+ timeoutMs?: number;
18
+ fetch?: typeof fetch;
19
+ }
20
+ /** Create a secretless-broker client for an edge runtime. Edge has no local bridge,
21
+ * so this always targets the cloud broker; pass config explicitly (edge runtimes
22
+ * have no `process.env`). See `@tillstack/secrets-node` for the auto/bridge mode. */
23
+ declare function createBroker(opts: CreateEdgeBrokerOptions): BrokerClient;
7
24
 
8
- export { createClient, createClient as default };
25
+ export { type CreateEdgeBrokerOptions, createBroker, createClient, createClient as default };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,25 @@
1
- import { SecretsClientOptions, SecretsClient } from '@tillstack/secrets-core';
1
+ import { BrokerClient, SecretsClientOptions, SecretsClient } from '@tillstack/secrets-core';
2
2
  export * from '@tillstack/secrets-core';
3
3
 
4
4
  /** Create a TillSecrets client. Pass an explicit `fetch` if the runtime has no
5
5
  * global one. */
6
6
  declare function createClient(opts: SecretsClientOptions): SecretsClient;
7
+ interface CreateEdgeBrokerOptions {
8
+ /** Cloud API base (derives the spend endpoint) — or pass `endpoint` directly. */
9
+ url?: string;
10
+ /** Full spend endpoint; overrides `url`. */
11
+ endpoint?: string;
12
+ /** Bearer token — a session / `tp_` API key (NOT the `ts_` service token). */
13
+ token: string;
14
+ /** Stable agent identity — required by the cloud broker. */
15
+ agentKey: string;
16
+ sessionId?: string;
17
+ timeoutMs?: number;
18
+ fetch?: typeof fetch;
19
+ }
20
+ /** Create a secretless-broker client for an edge runtime. Edge has no local bridge,
21
+ * so this always targets the cloud broker; pass config explicitly (edge runtimes
22
+ * have no `process.env`). See `@tillstack/secrets-node` for the auto/bridge mode. */
23
+ declare function createBroker(opts: CreateEdgeBrokerOptions): BrokerClient;
7
24
 
8
- export { createClient, createClient as default };
25
+ export { type CreateEdgeBrokerOptions, createBroker, createClient, createClient as default };
package/dist/index.js CHANGED
@@ -8,8 +8,17 @@ var secretsCore = require('@tillstack/secrets-core');
8
8
  function createClient(opts) {
9
9
  return new secretsCore.SecretsClient(opts);
10
10
  }
11
+ function createBroker(opts) {
12
+ const endpoint = opts.endpoint ?? `${(opts.url ?? "https://tilldev.dev").replace(/\/$/, "")}/api/secrets/broker/spend`;
13
+ const built = { endpoint, token: opts.token, agentKey: opts.agentKey };
14
+ if (opts.sessionId !== void 0) built.sessionId = opts.sessionId;
15
+ if (opts.timeoutMs !== void 0) built.timeoutMs = opts.timeoutMs;
16
+ if (opts.fetch) built.fetch = opts.fetch;
17
+ return new secretsCore.BrokerClient(built);
18
+ }
11
19
  var src_default = createClient;
12
20
 
21
+ exports.createBroker = createBroker;
13
22
  exports.createClient = createClient;
14
23
  exports.default = src_default;
15
24
  Object.keys(secretsCore).forEach(function (k) {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":["SecretsClient"],"mappings":";;;;;;;AAYO,SAAS,aAAa,IAAA,EAA2C;AACtE,EAAA,OAAO,IAAIA,0BAAc,IAAI,CAAA;AAC/B;AAEA,IAAO,WAAA,GAAQ","file":"index.js","sourcesContent":["// @tillstack/secrets-edge — TillSecrets client for edge runtimes.\n//\n// import { createClient } from '@tillstack/secrets-edge'\n// const secrets = createClient({ url: env.TILLSECRETS_URL, token: env.TILLSECRETS_TOKEN })\n// const { secrets: map } = await secrets.pull()\n\nimport { SecretsClient, type SecretsClientOptions } from '@tillstack/secrets-core'\n\nexport * from '@tillstack/secrets-core'\n\n/** Create a TillSecrets client. Pass an explicit `fetch` if the runtime has no\n * global one. */\nexport function createClient(opts: SecretsClientOptions): SecretsClient {\n return new SecretsClient(opts)\n}\n\nexport default createClient\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":["SecretsClient","BrokerClient"],"mappings":";;;;;;;AAYO,SAAS,aAAa,IAAA,EAA2C;AACtE,EAAA,OAAO,IAAIA,0BAAc,IAAI,CAAA;AAC/B;AAmBO,SAAS,aAAa,IAAA,EAA6C;AACxE,EAAA,MAAM,QAAA,GAAW,IAAA,CAAK,QAAA,IAAY,CAAA,EAAA,CAAI,IAAA,CAAK,OAAO,qBAAA,EAAuB,OAAA,CAAQ,KAAA,EAAO,EAAE,CAAC,CAAA,yBAAA,CAAA;AAC3F,EAAA,MAAM,KAAA,GAA6B,EAAE,QAAA,EAAU,KAAA,EAAO,KAAK,KAAA,EAAO,QAAA,EAAU,KAAK,QAAA,EAAS;AAC1F,EAAA,IAAI,IAAA,CAAK,SAAA,KAAc,MAAA,EAAW,KAAA,CAAM,YAAY,IAAA,CAAK,SAAA;AACzD,EAAA,IAAI,IAAA,CAAK,SAAA,KAAc,MAAA,EAAW,KAAA,CAAM,YAAY,IAAA,CAAK,SAAA;AACzD,EAAA,IAAI,IAAA,CAAK,KAAA,EAAO,KAAA,CAAM,KAAA,GAAQ,IAAA,CAAK,KAAA;AACnC,EAAA,OAAO,IAAIC,yBAAa,KAAK,CAAA;AAC/B;AAEA,IAAO,WAAA,GAAQ","file":"index.js","sourcesContent":["// @tillstack/secrets-edge — TillSecrets client for edge runtimes.\n//\n// import { createClient } from '@tillstack/secrets-edge'\n// const secrets = createClient({ url: env.TILLSECRETS_URL, token: env.TILLSECRETS_TOKEN })\n// const { secrets: map } = await secrets.pull()\n\nimport { SecretsClient, BrokerClient, type SecretsClientOptions, type BrokerClientOptions } from '@tillstack/secrets-core'\n\nexport * from '@tillstack/secrets-core'\n\n/** Create a TillSecrets client. Pass an explicit `fetch` if the runtime has no\n * global one. */\nexport function createClient(opts: SecretsClientOptions): SecretsClient {\n return new SecretsClient(opts)\n}\n\nexport interface CreateEdgeBrokerOptions {\n /** Cloud API base (derives the spend endpoint) — or pass `endpoint` directly. */\n url?: string\n /** Full spend endpoint; overrides `url`. */\n endpoint?: string\n /** Bearer token — a session / `tp_` API key (NOT the `ts_` service token). */\n token: string\n /** Stable agent identity — required by the cloud broker. */\n agentKey: string\n sessionId?: string\n timeoutMs?: number\n fetch?: typeof fetch\n}\n\n/** Create a secretless-broker client for an edge runtime. Edge has no local bridge,\n * so this always targets the cloud broker; pass config explicitly (edge runtimes\n * have no `process.env`). See `@tillstack/secrets-node` for the auto/bridge mode. */\nexport function createBroker(opts: CreateEdgeBrokerOptions): BrokerClient {\n const endpoint = opts.endpoint ?? `${(opts.url ?? 'https://tilldev.dev').replace(/\\/$/, '')}/api/secrets/broker/spend`\n const built: BrokerClientOptions = { endpoint, token: opts.token, agentKey: opts.agentKey }\n if (opts.sessionId !== undefined) built.sessionId = opts.sessionId\n if (opts.timeoutMs !== undefined) built.timeoutMs = opts.timeoutMs\n if (opts.fetch) built.fetch = opts.fetch\n return new BrokerClient(built)\n}\n\nexport default createClient\n"]}
package/dist/index.mjs CHANGED
@@ -1,12 +1,20 @@
1
- import { SecretsClient } from '@tillstack/secrets-core';
1
+ import { SecretsClient, BrokerClient } from '@tillstack/secrets-core';
2
2
  export * from '@tillstack/secrets-core';
3
3
 
4
4
  // src/index.ts
5
5
  function createClient(opts) {
6
6
  return new SecretsClient(opts);
7
7
  }
8
+ function createBroker(opts) {
9
+ const endpoint = opts.endpoint ?? `${(opts.url ?? "https://tilldev.dev").replace(/\/$/, "")}/api/secrets/broker/spend`;
10
+ const built = { endpoint, token: opts.token, agentKey: opts.agentKey };
11
+ if (opts.sessionId !== void 0) built.sessionId = opts.sessionId;
12
+ if (opts.timeoutMs !== void 0) built.timeoutMs = opts.timeoutMs;
13
+ if (opts.fetch) built.fetch = opts.fetch;
14
+ return new BrokerClient(built);
15
+ }
8
16
  var src_default = createClient;
9
17
 
10
- export { createClient, src_default as default };
18
+ export { createBroker, createClient, src_default as default };
11
19
  //# sourceMappingURL=index.mjs.map
12
20
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;AAYO,SAAS,aAAa,IAAA,EAA2C;AACtE,EAAA,OAAO,IAAI,cAAc,IAAI,CAAA;AAC/B;AAEA,IAAO,WAAA,GAAQ","file":"index.mjs","sourcesContent":["// @tillstack/secrets-edge — TillSecrets client for edge runtimes.\n//\n// import { createClient } from '@tillstack/secrets-edge'\n// const secrets = createClient({ url: env.TILLSECRETS_URL, token: env.TILLSECRETS_TOKEN })\n// const { secrets: map } = await secrets.pull()\n\nimport { SecretsClient, type SecretsClientOptions } from '@tillstack/secrets-core'\n\nexport * from '@tillstack/secrets-core'\n\n/** Create a TillSecrets client. Pass an explicit `fetch` if the runtime has no\n * global one. */\nexport function createClient(opts: SecretsClientOptions): SecretsClient {\n return new SecretsClient(opts)\n}\n\nexport default createClient\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;AAYO,SAAS,aAAa,IAAA,EAA2C;AACtE,EAAA,OAAO,IAAI,cAAc,IAAI,CAAA;AAC/B;AAmBO,SAAS,aAAa,IAAA,EAA6C;AACxE,EAAA,MAAM,QAAA,GAAW,IAAA,CAAK,QAAA,IAAY,CAAA,EAAA,CAAI,IAAA,CAAK,OAAO,qBAAA,EAAuB,OAAA,CAAQ,KAAA,EAAO,EAAE,CAAC,CAAA,yBAAA,CAAA;AAC3F,EAAA,MAAM,KAAA,GAA6B,EAAE,QAAA,EAAU,KAAA,EAAO,KAAK,KAAA,EAAO,QAAA,EAAU,KAAK,QAAA,EAAS;AAC1F,EAAA,IAAI,IAAA,CAAK,SAAA,KAAc,MAAA,EAAW,KAAA,CAAM,YAAY,IAAA,CAAK,SAAA;AACzD,EAAA,IAAI,IAAA,CAAK,SAAA,KAAc,MAAA,EAAW,KAAA,CAAM,YAAY,IAAA,CAAK,SAAA;AACzD,EAAA,IAAI,IAAA,CAAK,KAAA,EAAO,KAAA,CAAM,KAAA,GAAQ,IAAA,CAAK,KAAA;AACnC,EAAA,OAAO,IAAI,aAAa,KAAK,CAAA;AAC/B;AAEA,IAAO,WAAA,GAAQ","file":"index.mjs","sourcesContent":["// @tillstack/secrets-edge — TillSecrets client for edge runtimes.\n//\n// import { createClient } from '@tillstack/secrets-edge'\n// const secrets = createClient({ url: env.TILLSECRETS_URL, token: env.TILLSECRETS_TOKEN })\n// const { secrets: map } = await secrets.pull()\n\nimport { SecretsClient, BrokerClient, type SecretsClientOptions, type BrokerClientOptions } from '@tillstack/secrets-core'\n\nexport * from '@tillstack/secrets-core'\n\n/** Create a TillSecrets client. Pass an explicit `fetch` if the runtime has no\n * global one. */\nexport function createClient(opts: SecretsClientOptions): SecretsClient {\n return new SecretsClient(opts)\n}\n\nexport interface CreateEdgeBrokerOptions {\n /** Cloud API base (derives the spend endpoint) — or pass `endpoint` directly. */\n url?: string\n /** Full spend endpoint; overrides `url`. */\n endpoint?: string\n /** Bearer token — a session / `tp_` API key (NOT the `ts_` service token). */\n token: string\n /** Stable agent identity — required by the cloud broker. */\n agentKey: string\n sessionId?: string\n timeoutMs?: number\n fetch?: typeof fetch\n}\n\n/** Create a secretless-broker client for an edge runtime. Edge has no local bridge,\n * so this always targets the cloud broker; pass config explicitly (edge runtimes\n * have no `process.env`). See `@tillstack/secrets-node` for the auto/bridge mode. */\nexport function createBroker(opts: CreateEdgeBrokerOptions): BrokerClient {\n const endpoint = opts.endpoint ?? `${(opts.url ?? 'https://tilldev.dev').replace(/\\/$/, '')}/api/secrets/broker/spend`\n const built: BrokerClientOptions = { endpoint, token: opts.token, agentKey: opts.agentKey }\n if (opts.sessionId !== undefined) built.sessionId = opts.sessionId\n if (opts.timeoutMs !== undefined) built.timeoutMs = opts.timeoutMs\n if (opts.fetch) built.fetch = opts.fetch\n return new BrokerClient(built)\n}\n\nexport default createClient\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tillstack/secrets-edge",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "TillSecrets client for any edge runtime (Cloudflare Workers, Vercel Edge, Deno, Bun) — pull encrypted config over one authenticated fetch, zero Node built-ins.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -24,7 +24,7 @@
24
24
  "dist"
25
25
  ],
26
26
  "dependencies": {
27
- "@tillstack/secrets-core": "^0.2.1"
27
+ "@tillstack/secrets-core": "^0.3.0"
28
28
  },
29
29
  "devDependencies": {
30
30
  "tsup": "^8.5.1",