@enlitt/sdk 0.0.0-stage → 0.1.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 (117) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/LICENSE +21 -0
  3. package/README.md +63 -2
  4. package/dist/browser/auth.d.cts +44 -0
  5. package/dist/browser/auth.d.ts +45 -0
  6. package/dist/browser/auth.d.ts.map +1 -0
  7. package/dist/browser.cjs +35 -0
  8. package/dist/browser.cjs.map +1 -0
  9. package/dist/browser.d.cts +12 -0
  10. package/dist/browser.d.ts +13 -0
  11. package/dist/browser.d.ts.map +1 -0
  12. package/dist/browser.js +32 -0
  13. package/dist/browser.js.map +1 -0
  14. package/dist/chunk-2BGWYTJM.cjs +1097 -0
  15. package/dist/chunk-2BGWYTJM.cjs.map +1 -0
  16. package/dist/chunk-6OWXYBBT.cjs +146 -0
  17. package/dist/chunk-6OWXYBBT.cjs.map +1 -0
  18. package/dist/chunk-NI6WH5FI.js +33 -0
  19. package/dist/chunk-NI6WH5FI.js.map +1 -0
  20. package/dist/chunk-O6ASIA3X.js +866 -0
  21. package/dist/chunk-O6ASIA3X.js.map +1 -0
  22. package/dist/chunk-PPOUNWNA.cjs +895 -0
  23. package/dist/chunk-PPOUNWNA.cjs.map +1 -0
  24. package/dist/chunk-UVZMKGIL.js +1091 -0
  25. package/dist/chunk-UVZMKGIL.js.map +1 -0
  26. package/dist/chunk-V5TCSQ7C.js +143 -0
  27. package/dist/chunk-V5TCSQ7C.js.map +1 -0
  28. package/dist/chunk-YPA4R65T.cjs +35 -0
  29. package/dist/chunk-YPA4R65T.cjs.map +1 -0
  30. package/dist/core/errors.d.cts +262 -0
  31. package/dist/core/errors.d.ts +263 -0
  32. package/dist/core/errors.d.ts.map +1 -0
  33. package/dist/core/index.d.cts +24 -0
  34. package/dist/core/index.d.ts +25 -0
  35. package/dist/core/index.d.ts.map +1 -0
  36. package/dist/core/premium.d.cts +230 -0
  37. package/dist/core/premium.d.ts +231 -0
  38. package/dist/core/premium.d.ts.map +1 -0
  39. package/dist/core/session.d.cts +122 -0
  40. package/dist/core/session.d.ts +123 -0
  41. package/dist/core/session.d.ts.map +1 -0
  42. package/dist/core/sse.d.cts +79 -0
  43. package/dist/core/sse.d.ts +80 -0
  44. package/dist/core/sse.d.ts.map +1 -0
  45. package/dist/core/transport.d.cts +223 -0
  46. package/dist/core/transport.d.ts +224 -0
  47. package/dist/core/transport.d.ts.map +1 -0
  48. package/dist/core/usage.d.cts +35 -0
  49. package/dist/core/usage.d.ts +36 -0
  50. package/dist/core/usage.d.ts.map +1 -0
  51. package/dist/core.cjs +77 -0
  52. package/dist/core.cjs.map +1 -0
  53. package/dist/core.js +4 -0
  54. package/dist/core.js.map +1 -0
  55. package/dist/index.cjs +4 -0
  56. package/dist/index.cjs.map +1 -0
  57. package/dist/index.d.cts +16 -0
  58. package/dist/index.d.ts +17 -0
  59. package/dist/index.d.ts.map +1 -0
  60. package/dist/index.js +3 -0
  61. package/dist/index.js.map +1 -0
  62. package/dist/openai/client.d.cts +72 -0
  63. package/dist/openai/client.d.ts +73 -0
  64. package/dist/openai/client.d.ts.map +1 -0
  65. package/dist/openai/index.d.cts +2 -0
  66. package/dist/openai/index.d.ts +3 -0
  67. package/dist/openai/index.d.ts.map +1 -0
  68. package/dist/openai/media.d.cts +108 -0
  69. package/dist/openai/media.d.ts +109 -0
  70. package/dist/openai/media.d.ts.map +1 -0
  71. package/dist/openai.cjs +623 -0
  72. package/dist/openai.cjs.map +1 -0
  73. package/dist/openai.js +617 -0
  74. package/dist/openai.js.map +1 -0
  75. package/dist/server/callback.d.cts +107 -0
  76. package/dist/server/callback.d.ts +108 -0
  77. package/dist/server/callback.d.ts.map +1 -0
  78. package/dist/server/client-sign-in.d.cts +77 -0
  79. package/dist/server/client-sign-in.d.ts +78 -0
  80. package/dist/server/client-sign-in.d.ts.map +1 -0
  81. package/dist/server/index.d.cts +20 -0
  82. package/dist/server/index.d.ts +21 -0
  83. package/dist/server/index.d.ts.map +1 -0
  84. package/dist/server/secrets.d.cts +46 -0
  85. package/dist/server/secrets.d.ts +47 -0
  86. package/dist/server/secrets.d.ts.map +1 -0
  87. package/dist/server-unavailable.cjs +8 -0
  88. package/dist/server-unavailable.cjs.map +1 -0
  89. package/dist/server-unavailable.d.cts +10 -0
  90. package/dist/server-unavailable.d.ts +11 -0
  91. package/dist/server-unavailable.d.ts.map +1 -0
  92. package/dist/server-unavailable.js +6 -0
  93. package/dist/server-unavailable.js.map +1 -0
  94. package/dist/server.cjs +880 -0
  95. package/dist/server.cjs.map +1 -0
  96. package/dist/server.js +795 -0
  97. package/dist/server.js.map +1 -0
  98. package/dist/vercel/index.d.cts +17 -0
  99. package/dist/vercel/index.d.ts +18 -0
  100. package/dist/vercel/index.d.ts.map +1 -0
  101. package/dist/vercel/language-model.d.cts +146 -0
  102. package/dist/vercel/language-model.d.ts +147 -0
  103. package/dist/vercel/language-model.d.ts.map +1 -0
  104. package/dist/vercel/premium-language-model.d.cts +127 -0
  105. package/dist/vercel/premium-language-model.d.ts +128 -0
  106. package/dist/vercel/premium-language-model.d.ts.map +1 -0
  107. package/dist/vercel/premium-media-model.d.cts +101 -0
  108. package/dist/vercel/premium-media-model.d.ts +102 -0
  109. package/dist/vercel/premium-media-model.d.ts.map +1 -0
  110. package/dist/vercel/standard-language-model.d.cts +104 -0
  111. package/dist/vercel/standard-language-model.d.ts +105 -0
  112. package/dist/vercel/standard-language-model.d.ts.map +1 -0
  113. package/dist/vercel.cjs +22 -0
  114. package/dist/vercel.cjs.map +1 -0
  115. package/dist/vercel.js +5 -0
  116. package/dist/vercel.js.map +1 -0
  117. package/package.json +139 -3
@@ -0,0 +1,46 @@
1
+ /**
2
+ * The server-only boundary that turns a business secret into an outgoing
3
+ * authorization header.
4
+ *
5
+ * There is exactly one export. Resolving a key and formatting a header used to
6
+ * be two of them, which made "resolve the key and forget to use it" a
7
+ * reachable mistake at every call site; there is now no way to obtain the
8
+ * secret through this module's public surface without obtaining the header.
9
+ *
10
+ * A missing or unusable secret throws locally, before any network call, and
11
+ * never yields an unauthenticated client or a credential-free request. That
12
+ * local failure is what stops a managed premium call from silently falling
13
+ * through to a direct, business-funded provider call.
14
+ *
15
+ * The resolved value is a secret. It is never logged, never serialized into a
16
+ * thrown error's message or fields, and never returned to a caller: the
17
+ * `browser` condition on the `./server` subpath keeps this file out of every
18
+ * browser bundle, and the environment assertion below is the second net for a
19
+ * bundler or runtime that ignores that condition.
20
+ *
21
+ * Both local failures — a browser environment and an unusable secret — raise
22
+ * `EnlittConfigurationError`. That is what `enlitt()` documents its callers
23
+ * will see for a missing or invalid secret, and the type has to be right here
24
+ * rather than at one caller's boundary: any other caller of this function
25
+ * (`server/callback.ts`'s handlers among them) would otherwise receive a bare
26
+ * `Error` for exactly the same misconfiguration, and a business catching the
27
+ * package's own error class would miss it.
28
+ */
29
+ /**
30
+ * Resolve the business secret and return the one header value that carries it.
31
+ *
32
+ * Resolution order is explicit configuration first, then the `ENLITT_SECRET_KEY`
33
+ * environment fallback. An explicitly supplied key is never abandoned in
34
+ * favour of the environment: a business that passed an empty or malformed
35
+ * value has misconfigured that value, and silently authenticating as whatever
36
+ * the environment happens to hold would be a different identity than the one
37
+ * the call site asked for.
38
+ *
39
+ * @returns a single `Bearer <secret>` header value.
40
+ * @throws {EnlittConfigurationError} in a browser environment, or when no
41
+ * usable secret resolves. Neither the message nor any field of the thrown
42
+ * error carries any part of the secret.
43
+ */
44
+ export declare function resolveBusinessAuthorizationHeader(config: {
45
+ secretKey?: string;
46
+ }): string;
@@ -0,0 +1,47 @@
1
+ /**
2
+ * The server-only boundary that turns a business secret into an outgoing
3
+ * authorization header.
4
+ *
5
+ * There is exactly one export. Resolving a key and formatting a header used to
6
+ * be two of them, which made "resolve the key and forget to use it" a
7
+ * reachable mistake at every call site; there is now no way to obtain the
8
+ * secret through this module's public surface without obtaining the header.
9
+ *
10
+ * A missing or unusable secret throws locally, before any network call, and
11
+ * never yields an unauthenticated client or a credential-free request. That
12
+ * local failure is what stops a managed premium call from silently falling
13
+ * through to a direct, business-funded provider call.
14
+ *
15
+ * The resolved value is a secret. It is never logged, never serialized into a
16
+ * thrown error's message or fields, and never returned to a caller: the
17
+ * `browser` condition on the `./server` subpath keeps this file out of every
18
+ * browser bundle, and the environment assertion below is the second net for a
19
+ * bundler or runtime that ignores that condition.
20
+ *
21
+ * Both local failures — a browser environment and an unusable secret — raise
22
+ * `EnlittConfigurationError`. That is what `enlitt()` documents its callers
23
+ * will see for a missing or invalid secret, and the type has to be right here
24
+ * rather than at one caller's boundary: any other caller of this function
25
+ * (`server/callback.ts`'s handlers among them) would otherwise receive a bare
26
+ * `Error` for exactly the same misconfiguration, and a business catching the
27
+ * package's own error class would miss it.
28
+ */
29
+ /**
30
+ * Resolve the business secret and return the one header value that carries it.
31
+ *
32
+ * Resolution order is explicit configuration first, then the `ENLITT_SECRET_KEY`
33
+ * environment fallback. An explicitly supplied key is never abandoned in
34
+ * favour of the environment: a business that passed an empty or malformed
35
+ * value has misconfigured that value, and silently authenticating as whatever
36
+ * the environment happens to hold would be a different identity than the one
37
+ * the call site asked for.
38
+ *
39
+ * @returns a single `Bearer <secret>` header value.
40
+ * @throws {EnlittConfigurationError} in a browser environment, or when no
41
+ * usable secret resolves. Neither the message nor any field of the thrown
42
+ * error carries any part of the secret.
43
+ */
44
+ export declare function resolveBusinessAuthorizationHeader(config: {
45
+ secretKey?: string;
46
+ }): string;
47
+ //# sourceMappingURL=secrets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secrets.d.ts","sourceRoot":"","sources":["../../src/server/secrets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAmDH;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kCAAkC,CAAC,MAAM,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAsBzF"}
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ // src/server-unavailable.ts
4
+ throw new Error(
5
+ "This @enlitt/sdk entry (server, core, vercel, or openai) is a server-only entry point and was resolved in a browser bundle. Import it from server code only; use @enlitt/sdk/browser in code you ship to consumers."
6
+ );
7
+ //# sourceMappingURL=server-unavailable.cjs.map
8
+ //# sourceMappingURL=server-unavailable.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/server-unavailable.ts"],"names":[],"mappings":";;;AAUA,MAAM,IAAI,KAAA;AAAA,EACR;AAGF,CAAA","file":"server-unavailable.cjs","sourcesContent":["/**\n * The `browser` condition for `@enlitt/sdk/server`, `@enlitt/sdk/core`, and\n * `@enlitt/sdk/vercel`, and `@enlitt/sdk/openai` resolves here.\n *\n * A bundler that follows browser conditions can therefore never pull the real\n * server module — and with it `process.env.ENLITT_SECRET_KEY` — into a client\n * bundle. Failing at import time makes the mistake loud at build or first\n * load rather than silently shipping a secret read to consumers.\n */\n\nthrow new Error(\n \"This @enlitt/sdk entry (server, core, vercel, or openai) is a server-only entry point and was resolved in a \" +\n \"browser bundle. Import it from server code only; use @enlitt/sdk/browser \" +\n \"in code you ship to consumers.\"\n);\n\nexport {};\n"]}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The `browser` condition for `@enlitt/sdk/server`, `@enlitt/sdk/core`, and
3
+ * `@enlitt/sdk/vercel`, and `@enlitt/sdk/openai` resolves here.
4
+ *
5
+ * A bundler that follows browser conditions can therefore never pull the real
6
+ * server module — and with it `process.env.ENLITT_SECRET_KEY` — into a client
7
+ * bundle. Failing at import time makes the mistake loud at build or first
8
+ * load rather than silently shipping a secret read to consumers.
9
+ */
10
+ export {};
@@ -0,0 +1,11 @@
1
+ /**
2
+ * The `browser` condition for `@enlitt/sdk/server`, `@enlitt/sdk/core`, and
3
+ * `@enlitt/sdk/vercel`, and `@enlitt/sdk/openai` resolves here.
4
+ *
5
+ * A bundler that follows browser conditions can therefore never pull the real
6
+ * server module — and with it `process.env.ENLITT_SECRET_KEY` — into a client
7
+ * bundle. Failing at import time makes the mistake loud at build or first
8
+ * load rather than silently shipping a secret read to consumers.
9
+ */
10
+ export {};
11
+ //# sourceMappingURL=server-unavailable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-unavailable.d.ts","sourceRoot":"","sources":["../src/server-unavailable.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAQH,OAAO,EAAE,CAAC"}
@@ -0,0 +1,6 @@
1
+ // src/server-unavailable.ts
2
+ throw new Error(
3
+ "This @enlitt/sdk entry (server, core, vercel, or openai) is a server-only entry point and was resolved in a browser bundle. Import it from server code only; use @enlitt/sdk/browser in code you ship to consumers."
4
+ );
5
+ //# sourceMappingURL=server-unavailable.js.map
6
+ //# sourceMappingURL=server-unavailable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/server-unavailable.ts"],"names":[],"mappings":";AAUA,MAAM,IAAI,KAAA;AAAA,EACR;AAGF,CAAA","file":"server-unavailable.js","sourcesContent":["/**\n * The `browser` condition for `@enlitt/sdk/server`, `@enlitt/sdk/core`, and\n * `@enlitt/sdk/vercel`, and `@enlitt/sdk/openai` resolves here.\n *\n * A bundler that follows browser conditions can therefore never pull the real\n * server module — and with it `process.env.ENLITT_SECRET_KEY` — into a client\n * bundle. Failing at import time makes the mistake loud at build or first\n * load rather than silently shipping a secret read to consumers.\n */\n\nthrow new Error(\n \"This @enlitt/sdk entry (server, core, vercel, or openai) is a server-only entry point and was resolved in a \" +\n \"browser bundle. Import it from server code only; use @enlitt/sdk/browser \" +\n \"in code you ship to consumers.\"\n);\n\nexport {};\n"]}