@distilled.cloud/okta 1.0.0-rc.20 → 1.0.0-rc.22

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@distilled.cloud/okta",
3
- "version": "1.0.0-rc.20",
3
+ "version": "1.0.0-rc.22",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -57,6 +57,13 @@
57
57
  "worker": "./src/retry.ts",
58
58
  "default": "./lib/retry.js"
59
59
  },
60
+ "./unstable/*": {
61
+ "types": "./lib/unstable-services/*.d.ts",
62
+ "bun": "./src/unstable-services/*.ts",
63
+ "worker": "./src/unstable-services/*.ts",
64
+ "distilled-lazy": "./lib/unstable-services.lazy/*.js",
65
+ "default": "./lib/unstable-services/*.js"
66
+ },
60
67
  "./*": {
61
68
  "types": "./lib/services/*.d.ts",
62
69
  "bun": "./src/services/*.ts",
@@ -66,18 +73,18 @@
66
73
  }
67
74
  },
68
75
  "dependencies": {
69
- "@distilled.cloud/core": "1.0.0-rc.20"
76
+ "@distilled.cloud/core": "1.0.0-rc.22"
70
77
  },
71
78
  "devDependencies": {
72
79
  "@distilled.cloud/dev": "0.0.0",
73
80
  "@types/node": "26.6.5"
74
81
  },
75
82
  "peerDependencies": {
76
- "effect": "^4.1.2"
83
+ "effect": "~4.1.7"
77
84
  },
78
85
  "distilled": {
79
- "generatedAt": "2026-11-10",
80
- "specUpdatedAt": "2026-11-08"
86
+ "generatedAt": "2026-11-26",
87
+ "specUpdatedAt": "2026-11-23"
81
88
  },
82
89
  "scripts": {
83
90
  "build": "tsrs -b",
@@ -3,7 +3,7 @@ import { ConfigError } from "@distilled.cloud/core/errors";
3
3
  * Okta credentials -- hand-written.
4
4
  *
5
5
  * The `Credentials` service holds an *effect* that resolves the current
6
- * credentials on every request (the protocol layer resolves it per request
6
+ * credentials on every request (the protocol resolves it per request
7
7
  * on the calling fiber). Dual-mode auth:
8
8
  *
9
9
  * SSWS API token -> `Authorization: SSWS <apiToken>`
@@ -28,9 +28,7 @@ export interface Config {
28
28
  }
29
29
 
30
30
  export class Credentials
31
- extends /*@__PURE__*/ Context.Service<Credentials, Effect.Effect<Config, ConfigError>>()(
32
- "OktaCredentials",
33
- ) {}
31
+ extends /*@__PURE__*/ Context.Service<Credentials, Effect.Effect<Config>>()("OktaCredentials") {}
34
32
 
35
33
  const stripTrailingSlash = (url: string): string => url.replace(/\/+$/, "");
36
34
 
@@ -63,28 +61,34 @@ export const fromAccessToken = (config: {
63
61
  /**
64
62
  * Reads OKTA_API_TOKEN + OKTA_ORG_URL (required) and OKTA_AUTH_SCHEME
65
63
  * (optional, `SSWS` or `Bearer`; default SSWS).
64
+ *
65
+ * Its configuration is read and checked once, when the layer is built: a
66
+ * problem there fails the layer with `ConfigError`.
66
67
  */
67
- export const CredentialsFromEnv: Layer.Layer<Credentials> = /*@__PURE__*/ Layer.succeed(
68
+ export const CredentialsFromEnv: Layer.Layer<Credentials, ConfigError> = /*@__PURE__*/ Layer.effect(
68
69
  Credentials,
69
- /*@__PURE__*/ Effect.gen(function* () {
70
- const apiToken = process.env.OKTA_API_TOKEN;
71
- const apiBaseUrl = process.env.OKTA_ORG_URL;
72
- const scheme = process.env.OKTA_AUTH_SCHEME;
70
+ /*@__PURE__*/ Effect.map(
71
+ /*@__PURE__*/ Effect.gen(function* () {
72
+ const apiToken = process.env.OKTA_API_TOKEN;
73
+ const apiBaseUrl = process.env.OKTA_ORG_URL;
74
+ const scheme = process.env.OKTA_AUTH_SCHEME;
73
75
 
74
- if (!apiToken || !apiBaseUrl) {
75
- return yield* new ConfigError({
76
- message: "OKTA_API_TOKEN and OKTA_ORG_URL environment variables are required",
77
- });
78
- }
76
+ if (!apiToken || !apiBaseUrl) {
77
+ return yield* new ConfigError({
78
+ message: "OKTA_API_TOKEN and OKTA_ORG_URL environment variables are required",
79
+ });
80
+ }
79
81
 
80
- const authScheme: AuthScheme = scheme === "Bearer" || scheme === "SSWS" ? scheme : "SSWS";
82
+ const authScheme: AuthScheme = scheme === "Bearer" || scheme === "SSWS" ? scheme : "SSWS";
81
83
 
82
- return {
83
- apiToken: Redacted.make(apiToken),
84
- apiBaseUrl: stripTrailingSlash(apiBaseUrl),
85
- authScheme,
86
- };
87
- }),
84
+ return {
85
+ apiToken: Redacted.make(apiToken),
86
+ apiBaseUrl: stripTrailingSlash(apiBaseUrl),
87
+ authScheme,
88
+ };
89
+ }),
90
+ (config) => Effect.succeed(config),
91
+ ),
88
92
  );
89
93
 
90
94
  /** Auth headers for a resolved credentials config. */
package/src/errors.ts CHANGED
@@ -28,7 +28,7 @@ export {
28
28
  export type { DefaultErrors } from "@distilled.cloud/core/errors";
29
29
 
30
30
  import * as Category from "@distilled.cloud/core/category";
31
- import { UnknownErrorFields } from "@distilled.cloud/core/errors";
31
+ import { API_ERRORS, UnknownErrorFields } from "@distilled.cloud/core/errors";
32
32
  import * as Schema from "@distilled.cloud/core/schema-lite-typed";
33
33
 
34
34
  /** Unknown Okta error -- returned when nothing else matches the failure. */
@@ -44,3 +44,11 @@ export class OktaParseError
44
44
  body: Schema.Unknown,
45
45
  cause: Schema.Unknown,
46
46
  }).pipe(Category.withParseError) {}
47
+
48
+ /**
49
+ * The errors declared on the Okta service: any operation can return them, and
50
+ * every generated operation lists them as its `serviceErrors`. Today that is
51
+ * each of core's status classes (401, 403, 404, 429, the 5xx ...).
52
+ */
53
+ export const OktaServiceErrors = API_ERRORS;
54
+ export type OktaServiceError = InstanceType<(typeof OktaServiceErrors)[number]>;
package/src/protocol.ts CHANGED
@@ -1,16 +1,14 @@
1
- import type * as API from "@distilled.cloud/core/api";
2
- import type { API_ERRORS, ConfigError, InvalidInput } from "@distilled.cloud/core/errors";
1
+ import type { ErrorOf } from "@distilled.cloud/core/protocol";
3
2
  import {
4
- makeRestProtocol,
3
+ restProtocol,
5
4
  type RestErrorEnvelope,
6
5
  unknownErrorProps,
7
6
  } from "@distilled.cloud/core/protocol-rest";
8
- import type { SdkError } from "@distilled.cloud/core/sdk-error";
9
7
  /**
10
8
  * OktaProtocol -- hand-written.
11
9
  *
12
10
  * Okta speaks JSON REST (no response envelope), so the whole protocol is one
13
- * `makeRestProtocol` call from `core/protocol-rest`:
11
+ * `restProtocol` call from `core/protocol-rest`:
14
12
  *
15
13
  * request: credentials -> `Authorization: SSWS <apiToken>` (API token) or
16
14
  * `Authorization: Bearer <apiToken>` (OAuth) + org base URL
@@ -24,25 +22,17 @@ import type { SdkError } from "@distilled.cloud/core/sdk-error";
24
22
  */
25
23
  import * as Effect from "effect/Effect";
26
24
  import type * as HttpClient from "effect/http/HttpClient";
27
- import type * as HttpClientError from "effect/http/HttpClientError";
28
- import type * as Layer from "effect/Layer";
29
- import { Credentials, formatHeaders, type Config } from "./credentials.ts";
30
- import { UnknownOktaError, OktaParseError } from "./errors.ts";
25
+ import { Credentials, formatHeaders } from "./credentials.ts";
26
+ import { UnknownOktaError, OktaParseError, type OktaServiceError } from "./errors.ts";
31
27
 
32
28
  /**
33
- * Error channel shared by every generated Okta operation. Generated service
34
- * files annotate operations with `API.OperationMethod<I, O, OktaOpError,
35
- * OktaOpContext>` explicitly so the compiler never infers these back out of
36
- * the schema generics.
29
+ * What every generated Okta operation fails with besides its own errors: the
30
+ * service's errors, the protocol's, and what resolving the credentials fails
31
+ * with. Generated service files annotate operations with
32
+ * `API.OperationMethod<I, O, OktaOpError, OktaOpContext>` explicitly so the
33
+ * compiler never infers these back out of the schema generics.
37
34
  */
38
- export type OktaOpError =
39
- | InstanceType<(typeof API_ERRORS)[number]>
40
- | UnknownOktaError
41
- | ConfigError
42
- | HttpClientError.HttpClientError
43
- | OktaParseError
44
- | InvalidInput
45
- | SdkError;
35
+ export type OktaOpError = OktaServiceError | ErrorOf<typeof OktaProtocol>;
46
36
 
47
37
  /** Context (requirements) shared by every generated Okta operation. */
48
38
  export type OktaOpContext = Credentials | HttpClient.HttpClient;
@@ -67,10 +57,10 @@ const errorEnvelope = (body: unknown): RestErrorEnvelope | undefined => {
67
57
  return { code, message };
68
58
  };
69
59
 
70
- export const OktaProtocol: Layer.Layer<API.Protocol> = /*@__PURE__*/ makeRestProtocol<Config>({
60
+ export const OktaProtocol = /*@__PURE__*/ restProtocol({
71
61
  // The Credentials service holds an effect -- resolving it here (per
72
62
  // request, on the calling fiber) picks up context-provided credentials.
73
- credentials: /*@__PURE__*/ Effect.flatMap(Credentials, (resolve) => resolve),
63
+ credentials: /*@__PURE__*/ Effect.flatten(Credentials),
74
64
  baseUrl: (creds) => creds.apiBaseUrl,
75
65
  headers: (creds) => formatHeaders(creds),
76
66
  errorEnvelope,