@distilled.cloud/okta 1.0.0-rc.12 → 1.0.0-rc.14
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 +34 -0
- package/lib/credentials.d.ts +2 -2
- package/lib/credentials.d.ts.map +1 -1
- package/lib/credentials.js +2 -2
- package/lib/credentials.js.map +1 -1
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +1 -1
- package/lib/errors.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/protocol.d.ts +5 -5
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +5 -12
- package/lib/protocol.js.map +1 -1
- package/lib/retry.d.ts +1 -1
- package/lib/retry.d.ts.map +1 -1
- package/lib/retry.js +1 -1
- package/lib/retry.js.map +1 -1
- package/lib/services/okta.d.ts +276 -46
- package/lib/services/okta.d.ts.map +1 -1
- package/lib/services/okta.js +1330 -3801
- package/lib/services/okta.js.map +1 -1
- package/package.json +13 -11
- package/src/credentials.ts +9 -12
- package/src/errors.ts +10 -16
- package/src/index.ts +2 -12
- package/src/protocol.ts +26 -38
- package/src/retry.ts +2 -8
- package/src/services/okta.ts +5503 -10330
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@distilled.cloud/okta",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.14",
|
|
4
|
+
"license": "Apache-2.0",
|
|
4
5
|
"repository": {
|
|
5
6
|
"type": "git",
|
|
6
7
|
"url": "https://github.com/alchemy-run/distilled",
|
|
7
8
|
"directory": "packages/okta"
|
|
8
9
|
},
|
|
9
|
-
"license": "Apache-2.0",
|
|
10
|
-
"type": "module",
|
|
11
|
-
"sideEffects": false,
|
|
12
10
|
"files": [
|
|
13
11
|
"lib",
|
|
14
12
|
"src"
|
|
15
13
|
],
|
|
14
|
+
"type": "module",
|
|
15
|
+
"sideEffects": false,
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
18
18
|
"types": "./lib/index.d.ts",
|
|
@@ -64,20 +64,22 @@
|
|
|
64
64
|
}
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@distilled.cloud/core": "1.0.0-rc.
|
|
67
|
+
"@distilled.cloud/core": "1.0.0-rc.14"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
|
-
"@types/
|
|
71
|
-
"@types/node": "26.2.0",
|
|
72
|
-
"@effect/platform-bun": ">=4.0.0-rc.115 || >=4.0.0"
|
|
70
|
+
"@types/node": "26.2.0"
|
|
73
71
|
},
|
|
74
72
|
"peerDependencies": {
|
|
75
|
-
"effect": "
|
|
73
|
+
"effect": "^4.0.0"
|
|
74
|
+
},
|
|
75
|
+
"distilled": {
|
|
76
|
+
"generatedAt": "2026-10-06",
|
|
77
|
+
"specUpdatedAt": "2026-10-05"
|
|
76
78
|
},
|
|
77
79
|
"scripts": {
|
|
78
80
|
"build": "tsc -b",
|
|
79
|
-
"convert": "bun scripts/convert.ts",
|
|
80
|
-
"generate": "bun scripts/convert.ts && bun scripts/generate.ts",
|
|
81
|
+
"convert": "node --conditions=bun scripts/convert.ts",
|
|
82
|
+
"generate": "node --conditions=bun scripts/convert.ts && node --conditions=bun scripts/generate.ts",
|
|
81
83
|
"typecheck": "tsc -p tsconfig.json",
|
|
82
84
|
"specs:fetch": "git submodule update --force --init --depth=1 specs/spec-mirror-okta",
|
|
83
85
|
"specs:update": "git submodule update --remote --force --depth=1 specs/spec-mirror-okta"
|
package/src/credentials.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ConfigError } from "@distilled.cloud/core/errors";
|
|
1
2
|
/**
|
|
2
3
|
* Okta credentials — hand-written.
|
|
3
4
|
*
|
|
@@ -16,7 +17,6 @@ import * as Context from "effect/Context";
|
|
|
16
17
|
import * as Effect from "effect/Effect";
|
|
17
18
|
import * as Layer from "effect/Layer";
|
|
18
19
|
import * as Redacted from "effect/Redacted";
|
|
19
|
-
import { ConfigError } from "@distilled.cloud/core/errors";
|
|
20
20
|
|
|
21
21
|
/** Okta Management API token schemes. */
|
|
22
22
|
export type AuthScheme = "SSWS" | "Bearer";
|
|
@@ -27,23 +27,22 @@ export interface Config {
|
|
|
27
27
|
readonly authScheme: AuthScheme;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export class Credentials extends Context.Service<
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
>()("OktaCredentials") {}
|
|
30
|
+
export class Credentials extends Context.Service<Credentials, Effect.Effect<Config>>()(
|
|
31
|
+
"OktaCredentials",
|
|
32
|
+
) {}
|
|
34
33
|
|
|
35
34
|
const stripTrailingSlash = (url: string): string => url.replace(/\/+$/, "");
|
|
36
35
|
|
|
37
36
|
/** Layer from an SSWS API token + org base URL. */
|
|
38
37
|
export const fromApiToken = (config: {
|
|
39
|
-
readonly apiToken: string
|
|
38
|
+
readonly apiToken: Redacted.Redacted<string>;
|
|
40
39
|
readonly apiBaseUrl: string;
|
|
41
40
|
readonly authScheme?: AuthScheme;
|
|
42
41
|
}): Layer.Layer<Credentials> =>
|
|
43
42
|
Layer.succeed(
|
|
44
43
|
Credentials,
|
|
45
44
|
Effect.succeed({
|
|
46
|
-
apiToken:
|
|
45
|
+
apiToken: config.apiToken,
|
|
47
46
|
apiBaseUrl: stripTrailingSlash(config.apiBaseUrl),
|
|
48
47
|
authScheme: config.authScheme ?? "SSWS",
|
|
49
48
|
}),
|
|
@@ -51,7 +50,7 @@ export const fromApiToken = (config: {
|
|
|
51
50
|
|
|
52
51
|
/** Layer from an OAuth 2.0 access token + org base URL. */
|
|
53
52
|
export const fromAccessToken = (config: {
|
|
54
|
-
readonly accessToken: string
|
|
53
|
+
readonly accessToken: Redacted.Redacted<string>;
|
|
55
54
|
readonly apiBaseUrl: string;
|
|
56
55
|
}): Layer.Layer<Credentials> =>
|
|
57
56
|
fromApiToken({
|
|
@@ -73,13 +72,11 @@ export const CredentialsFromEnv: Layer.Layer<Credentials> = Layer.succeed(
|
|
|
73
72
|
|
|
74
73
|
if (!apiToken || !apiBaseUrl) {
|
|
75
74
|
return yield* new ConfigError({
|
|
76
|
-
message:
|
|
77
|
-
"OKTA_API_TOKEN and OKTA_ORG_URL environment variables are required",
|
|
75
|
+
message: "OKTA_API_TOKEN and OKTA_ORG_URL environment variables are required",
|
|
78
76
|
});
|
|
79
77
|
}
|
|
80
78
|
|
|
81
|
-
const authScheme: AuthScheme =
|
|
82
|
-
scheme === "Bearer" || scheme === "SSWS" ? scheme : "SSWS";
|
|
79
|
+
const authScheme: AuthScheme = scheme === "Bearer" || scheme === "SSWS" ? scheme : "SSWS";
|
|
83
80
|
|
|
84
81
|
return {
|
|
85
82
|
apiToken: Redacted.make(apiToken),
|
package/src/errors.ts
CHANGED
|
@@ -27,24 +27,18 @@ export {
|
|
|
27
27
|
} from "@distilled.cloud/core/errors";
|
|
28
28
|
export type { DefaultErrors } from "@distilled.cloud/core/errors";
|
|
29
29
|
|
|
30
|
-
import * as Schema from "effect/Schema";
|
|
31
30
|
import * as Category from "@distilled.cloud/core/category";
|
|
31
|
+
import * as Schema from "effect/Schema";
|
|
32
32
|
|
|
33
33
|
/** Unknown Okta error — returned when nothing else matches the failure. */
|
|
34
|
-
export class UnknownOktaError extends Schema.TaggedError<UnknownOktaError>()(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
body: Schema.Unknown,
|
|
40
|
-
},
|
|
41
|
-
).pipe(Category.withServerError) {}
|
|
34
|
+
export class UnknownOktaError extends Schema.TaggedError<UnknownOktaError>()("UnknownOktaError", {
|
|
35
|
+
code: Schema.optional(Schema.String),
|
|
36
|
+
message: Schema.optional(Schema.String),
|
|
37
|
+
body: Schema.Unknown,
|
|
38
|
+
}).pipe(Category.withServerError) {}
|
|
42
39
|
|
|
43
40
|
/** Schema parse error wrapper (kept for surface parity with other SDKs). */
|
|
44
|
-
export class OktaParseError extends Schema.TaggedError<OktaParseError>()(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
cause: Schema.Unknown,
|
|
49
|
-
},
|
|
50
|
-
).pipe(Category.withParseError) {}
|
|
41
|
+
export class OktaParseError extends Schema.TaggedError<OktaParseError>()("OktaParseError", {
|
|
42
|
+
body: Schema.Unknown,
|
|
43
|
+
cause: Schema.Unknown,
|
|
44
|
+
}).pipe(Category.withParseError) {}
|
package/src/index.ts
CHANGED
|
@@ -15,11 +15,7 @@
|
|
|
15
15
|
export * from "./credentials.ts";
|
|
16
16
|
export * from "./errors.ts";
|
|
17
17
|
export * as T from "./traits.ts";
|
|
18
|
-
export {
|
|
19
|
-
OktaProtocol,
|
|
20
|
-
type OktaOpError,
|
|
21
|
-
type OktaOpContext,
|
|
22
|
-
} from "./protocol.ts";
|
|
18
|
+
export { OktaProtocol, type OktaOpError, type OktaOpContext } from "./protocol.ts";
|
|
23
19
|
export { paginateCursor } from "./pagination.ts";
|
|
24
20
|
export * as Retry from "./retry.ts";
|
|
25
21
|
export * as Services from "./services/index.ts";
|
|
@@ -28,10 +24,4 @@ export * as Services from "./services/index.ts";
|
|
|
28
24
|
// same-named shared ones from ./errors.ts — the ops actually raise the
|
|
29
25
|
// service-local classes.
|
|
30
26
|
export * from "./services/okta.ts";
|
|
31
|
-
export {
|
|
32
|
-
BadRequest,
|
|
33
|
-
Conflict,
|
|
34
|
-
Forbidden,
|
|
35
|
-
NotFound,
|
|
36
|
-
UnprocessableEntity,
|
|
37
|
-
} from "./services/okta.ts";
|
|
27
|
+
export { BadRequest, Conflict, Forbidden, NotFound, UnprocessableEntity } from "./services/okta.ts";
|
package/src/protocol.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type * as API from "@distilled.cloud/core/api";
|
|
2
|
+
import type { API_ERRORS, ConfigError } from "@distilled.cloud/core/errors";
|
|
3
|
+
import { makeRestProtocol, type RestErrorEnvelope } from "@distilled.cloud/core/protocol-rest";
|
|
1
4
|
/**
|
|
2
5
|
* OktaProtocol — hand-written.
|
|
3
6
|
*
|
|
@@ -15,17 +18,11 @@
|
|
|
15
18
|
* shared HTTP-status classes, then {@link UnknownOktaError}.
|
|
16
19
|
*/
|
|
17
20
|
import * as Effect from "effect/Effect";
|
|
21
|
+
import type * as HttpClient from "effect/http/HttpClient";
|
|
22
|
+
import type * as HttpClientError from "effect/http/HttpClientError";
|
|
18
23
|
import type * as Layer from "effect/Layer";
|
|
19
|
-
import type * as HttpClient from "effect/unstable/http/HttpClient";
|
|
20
|
-
import type * as HttpClientError from "effect/unstable/http/HttpClientError";
|
|
21
|
-
import type * as API from "@distilled.cloud/core/api";
|
|
22
|
-
import {
|
|
23
|
-
makeRestProtocol,
|
|
24
|
-
type RestErrorEnvelope,
|
|
25
|
-
} from "@distilled.cloud/core/protocol-rest";
|
|
26
|
-
import type { API_ERRORS, ConfigError } from "@distilled.cloud/core/errors";
|
|
27
24
|
import { Credentials, formatHeaders, type Config } from "./credentials.ts";
|
|
28
|
-
import { UnknownOktaError } from "./errors.ts";
|
|
25
|
+
import { UnknownOktaError, OktaParseError } from "./errors.ts";
|
|
29
26
|
|
|
30
27
|
/**
|
|
31
28
|
* Error channel shared by every generated Okta operation. Generated service
|
|
@@ -37,7 +34,8 @@ export type OktaOpError =
|
|
|
37
34
|
| InstanceType<(typeof API_ERRORS)[number]>
|
|
38
35
|
| UnknownOktaError
|
|
39
36
|
| ConfigError
|
|
40
|
-
| HttpClientError.HttpClientError
|
|
37
|
+
| HttpClientError.HttpClientError
|
|
38
|
+
| OktaParseError;
|
|
41
39
|
|
|
42
40
|
/** Context (requirements) shared by every generated Okta operation. */
|
|
43
41
|
export type OktaOpContext = Credentials | HttpClient.HttpClient;
|
|
@@ -51,11 +49,7 @@ const errorEnvelope = (body: unknown): RestErrorEnvelope | undefined => {
|
|
|
51
49
|
if (body === null || typeof body !== "object") return undefined;
|
|
52
50
|
const b = body as Record<string, unknown>;
|
|
53
51
|
const code =
|
|
54
|
-
typeof b.errorCode === "string"
|
|
55
|
-
? b.errorCode
|
|
56
|
-
: typeof b.code === "string"
|
|
57
|
-
? b.code
|
|
58
|
-
: undefined;
|
|
52
|
+
typeof b.errorCode === "string" ? b.errorCode : typeof b.code === "string" ? b.code : undefined;
|
|
59
53
|
const message =
|
|
60
54
|
typeof b.errorSummary === "string"
|
|
61
55
|
? b.errorSummary
|
|
@@ -66,27 +60,21 @@ const errorEnvelope = (body: unknown): RestErrorEnvelope | undefined => {
|
|
|
66
60
|
return { code, message };
|
|
67
61
|
};
|
|
68
62
|
|
|
69
|
-
export const OktaProtocol: Layer.Layer<API.Protocol> = makeRestProtocol<Config>(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
63
|
+
export const OktaProtocol: Layer.Layer<API.Protocol> = makeRestProtocol<Config>({
|
|
64
|
+
// The Credentials service holds an effect — resolving it here (per
|
|
65
|
+
// request, on the calling fiber) picks up context-provided credentials.
|
|
66
|
+
credentials: Effect.gen(function* () {
|
|
67
|
+
const resolve = yield* Credentials;
|
|
68
|
+
return yield* resolve;
|
|
69
|
+
}),
|
|
70
|
+
baseUrl: (creds) => creds.apiBaseUrl,
|
|
71
|
+
headers: (creds) => formatHeaders(creds),
|
|
72
|
+
errorEnvelope,
|
|
73
|
+
unknownError: ({ code, message, body }) =>
|
|
74
|
+
new UnknownOktaError({
|
|
75
|
+
code: typeof code === "string" ? code : code !== undefined ? String(code) : undefined,
|
|
76
|
+
message,
|
|
77
|
+
body,
|
|
76
78
|
}),
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
errorEnvelope,
|
|
80
|
-
unknownError: ({ code, message, body }) =>
|
|
81
|
-
new UnknownOktaError({
|
|
82
|
-
code:
|
|
83
|
-
typeof code === "string"
|
|
84
|
-
? code
|
|
85
|
-
: code !== undefined
|
|
86
|
-
? String(code)
|
|
87
|
-
: undefined,
|
|
88
|
-
message,
|
|
89
|
-
body,
|
|
90
|
-
}),
|
|
91
|
-
},
|
|
92
|
-
);
|
|
79
|
+
parseError: ({ body, cause }) => new OktaParseError({ body, cause }),
|
|
80
|
+
});
|
package/src/retry.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Policy, throttlingFactory, transientFactory } from "@distilled.cloud/core/retry";
|
|
1
2
|
/**
|
|
2
3
|
* Okta retry configuration.
|
|
3
4
|
*
|
|
@@ -16,11 +17,6 @@
|
|
|
16
17
|
import * as Context from "effect/Context";
|
|
17
18
|
import * as Effect from "effect/Effect";
|
|
18
19
|
import * as Layer from "effect/Layer";
|
|
19
|
-
import {
|
|
20
|
-
type Policy,
|
|
21
|
-
throttlingFactory,
|
|
22
|
-
transientFactory,
|
|
23
|
-
} from "@distilled.cloud/core/retry";
|
|
24
20
|
|
|
25
21
|
export {
|
|
26
22
|
type Options,
|
|
@@ -43,9 +39,7 @@ export const policy = (optionsOrFactory: Policy) =>
|
|
|
43
39
|
Effect.provide(Layer.succeed(Retry, optionsOrFactory));
|
|
44
40
|
|
|
45
41
|
/** Disables all automatic retries. */
|
|
46
|
-
export const none = Effect.provide(
|
|
47
|
-
Layer.succeed(Retry, { while: () => false }),
|
|
48
|
-
);
|
|
42
|
+
export const none = Effect.provide(Layer.succeed(Retry, { while: () => false }));
|
|
49
43
|
|
|
50
44
|
/** Apply the throttling retry policy (retries throttling errors indefinitely). */
|
|
51
45
|
export const throttling = policy(throttlingFactory);
|