@distilled.cloud/okta 1.0.0-rc.19 → 1.0.0-rc.21
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/README.md +12 -1
- package/lib/.lazy.json +1 -1
- package/lib/_bundle/sdk.js +1 -1
- package/lib/_bundle/sdk.js.map +1 -1
- package/lib/credentials.d.ts +6 -3
- package/lib/credentials.d.ts.map +1 -1
- package/lib/errors.d.ts +12 -8
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.lazy.js.map +1 -1
- package/lib/pagination.d.ts.map +1 -1
- package/lib/protocol.d.ts +9 -12
- package/lib/protocol.d.ts.map +1 -1
- package/lib/retry.d.ts.map +1 -1
- package/lib/services/index.d.ts.map +1 -1
- package/lib/services/okta.d.ts +10038 -4026
- package/lib/services/okta.d.ts.map +1 -1
- package/lib/services/okta.js +930 -944
- package/lib/services/okta.js.map +1 -1
- package/lib/services.lazy/okta.js +2 -2
- package/lib/traits.d.ts.map +1 -1
- package/lib/unstable-services/index.d.ts +2 -0
- package/lib/unstable-services/index.d.ts.map +1 -0
- package/lib/unstable-services/index.js +1 -0
- package/lib/unstable-services/okta.d.ts +541 -0
- package/lib/unstable-services/okta.d.ts.map +1 -0
- package/lib/unstable-services/okta.js +2 -0
- package/lib/unstable-services/okta.js.map +1 -0
- package/lib/unstable-services.lazy/index.js +3 -0
- package/lib/unstable-services.lazy/okta.js +1 -0
- package/package.json +12 -5
- package/src/credentials.ts +25 -21
- package/src/errors.ts +13 -5
- package/src/protocol.ts +18 -29
- package/src/services/okta.ts +14246 -7131
- package/src/unstable-services/index.ts +2 -0
- package/src/unstable-services/okta.ts +895 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@distilled.cloud/okta",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.21",
|
|
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.
|
|
76
|
+
"@distilled.cloud/core": "1.0.0-rc.21"
|
|
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": "
|
|
83
|
+
"effect": "~4.1.7"
|
|
77
84
|
},
|
|
78
85
|
"distilled": {
|
|
79
|
-
"generatedAt": "2026-11-
|
|
80
|
-
"specUpdatedAt": "2026-11-
|
|
86
|
+
"generatedAt": "2026-11-26",
|
|
87
|
+
"specUpdatedAt": "2026-11-23"
|
|
81
88
|
},
|
|
82
89
|
"scripts": {
|
|
83
90
|
"build": "tsrs -b",
|
package/src/credentials.ts
CHANGED
|
@@ -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
|
|
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
|
|
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.
|
|
68
|
+
export const CredentialsFromEnv: Layer.Layer<Credentials, ConfigError> = /*@__PURE__*/ Layer.effect(
|
|
68
69
|
Credentials,
|
|
69
|
-
/*@__PURE__*/ Effect.
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
|
|
82
|
+
const authScheme: AuthScheme = scheme === "Bearer" || scheme === "SSWS" ? scheme : "SSWS";
|
|
81
83
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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,15 +28,15 @@ 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 { API_ERRORS, UnknownErrorFields } from "@distilled.cloud/core/errors";
|
|
31
32
|
import * as Schema from "@distilled.cloud/core/schema-lite-typed";
|
|
32
33
|
|
|
33
34
|
/** Unknown Okta error -- returned when nothing else matches the failure. */
|
|
34
35
|
export class UnknownOktaError
|
|
35
|
-
extends /*@__PURE__*/ Schema.TaggedError<UnknownOktaError>()(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}).pipe(Category.withServerError) {}
|
|
36
|
+
extends /*@__PURE__*/ Schema.TaggedError<UnknownOktaError>()(
|
|
37
|
+
"UnknownOktaError",
|
|
38
|
+
UnknownErrorFields,
|
|
39
|
+
) {}
|
|
40
40
|
|
|
41
41
|
/** Schema parse error wrapper (kept for surface parity with other SDKs). */
|
|
42
42
|
export class OktaParseError
|
|
@@ -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,12 +1,14 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import type { ErrorOf } from "@distilled.cloud/core/protocol";
|
|
2
|
+
import {
|
|
3
|
+
restProtocol,
|
|
4
|
+
type RestErrorEnvelope,
|
|
5
|
+
unknownErrorProps,
|
|
6
|
+
} from "@distilled.cloud/core/protocol-rest";
|
|
5
7
|
/**
|
|
6
8
|
* OktaProtocol -- hand-written.
|
|
7
9
|
*
|
|
8
10
|
* Okta speaks JSON REST (no response envelope), so the whole protocol is one
|
|
9
|
-
* `
|
|
11
|
+
* `restProtocol` call from `core/protocol-rest`:
|
|
10
12
|
*
|
|
11
13
|
* request: credentials -> `Authorization: SSWS <apiToken>` (API token) or
|
|
12
14
|
* `Authorization: Bearer <apiToken>` (OAuth) + org base URL
|
|
@@ -20,25 +22,17 @@ import type { SdkError } from "@distilled.cloud/core/sdk-error";
|
|
|
20
22
|
*/
|
|
21
23
|
import * as Effect from "effect/Effect";
|
|
22
24
|
import type * as HttpClient from "effect/http/HttpClient";
|
|
23
|
-
import
|
|
24
|
-
import type
|
|
25
|
-
import { Credentials, formatHeaders, type Config } from "./credentials.ts";
|
|
26
|
-
import { UnknownOktaError, OktaParseError } from "./errors.ts";
|
|
25
|
+
import { Credentials, formatHeaders } from "./credentials.ts";
|
|
26
|
+
import { UnknownOktaError, OktaParseError, type OktaServiceError } from "./errors.ts";
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
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.
|
|
33
34
|
*/
|
|
34
|
-
export type OktaOpError =
|
|
35
|
-
| InstanceType<(typeof API_ERRORS)[number]>
|
|
36
|
-
| UnknownOktaError
|
|
37
|
-
| ConfigError
|
|
38
|
-
| HttpClientError.HttpClientError
|
|
39
|
-
| OktaParseError
|
|
40
|
-
| InvalidInput
|
|
41
|
-
| SdkError;
|
|
35
|
+
export type OktaOpError = OktaServiceError | ErrorOf<typeof OktaProtocol>;
|
|
42
36
|
|
|
43
37
|
/** Context (requirements) shared by every generated Okta operation. */
|
|
44
38
|
export type OktaOpContext = Credentials | HttpClient.HttpClient;
|
|
@@ -63,18 +57,13 @@ const errorEnvelope = (body: unknown): RestErrorEnvelope | undefined => {
|
|
|
63
57
|
return { code, message };
|
|
64
58
|
};
|
|
65
59
|
|
|
66
|
-
export const OktaProtocol
|
|
60
|
+
export const OktaProtocol = /*@__PURE__*/ restProtocol({
|
|
67
61
|
// The Credentials service holds an effect -- resolving it here (per
|
|
68
62
|
// request, on the calling fiber) picks up context-provided credentials.
|
|
69
|
-
credentials: /*@__PURE__*/ Effect.
|
|
63
|
+
credentials: /*@__PURE__*/ Effect.flatten(Credentials),
|
|
70
64
|
baseUrl: (creds) => creds.apiBaseUrl,
|
|
71
65
|
headers: (creds) => formatHeaders(creds),
|
|
72
66
|
errorEnvelope,
|
|
73
|
-
unknownError: (
|
|
74
|
-
new UnknownOktaError({
|
|
75
|
-
code: typeof code === "string" ? code : code !== undefined ? String(code) : undefined,
|
|
76
|
-
message,
|
|
77
|
-
body,
|
|
78
|
-
}),
|
|
67
|
+
unknownError: (info) => new UnknownOktaError(unknownErrorProps(info)),
|
|
79
68
|
parseError: ({ body, cause }) => new OktaParseError({ body, cause }),
|
|
80
69
|
});
|