@statelyai/sdk 0.11.0 → 0.12.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.
- package/README.md +32 -1
- package/dist/auth-DO1-eQcU.d.mts +15 -0
- package/dist/auth.d.mts +2 -0
- package/dist/auth.mjs +11 -0
- package/dist/dist-C-AdA8Iw.mjs +9195 -0
- package/dist/{graphToXStateTS-DV62vO_d.mjs → dist-cQdIPK_n.mjs} +3755 -51
- package/dist/embed.d.mts +3 -2
- package/dist/embed.mjs +9 -1
- package/dist/{graph-GeuH-mFK.d.mts → graph-Bm4_GZX_.d.mts} +2 -262
- package/dist/graph.d.mts +1 -1
- package/dist/index-BpUKBSiq.d.mts +2843 -0
- package/dist/index.d.mts +7 -58
- package/dist/index.mjs +5 -3
- package/dist/{inspect-CZ8iLJR7.d.mts → inspect-BmZUcnZB.d.mts} +2 -1
- package/dist/inspect.d.mts +3 -3
- package/dist/inspect.mjs +3 -2
- package/dist/oauth.d.mts +77 -0
- package/dist/oauth.mjs +118 -0
- package/dist/patchTypes.d.mts +2 -249
- package/dist/protocol.d.mts +30 -2
- package/dist/studio.d.mts +8 -1
- package/dist/studio.mjs +21 -7
- package/dist/sync.d.mts +1 -1
- package/dist/sync.mjs +1 -3091
- package/dist/{transport-CVZGF0w9.mjs → transport-D0nlFaLn.mjs} +2 -0
- package/package.json +11 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { StatelyApiClientOptions, StatelyApiError, StatelyApiUrlOptions, createStatelyApiClient, createStatelyApiUrl } from "./api.mjs";
|
|
2
|
-
import { CommentsConfig, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedMode, ExportCallOptions, ExportFormat, ExportFormatMap, InitOptions, ProjectEmbedMachine, UploadResult } from "./protocol.mjs";
|
|
2
|
+
import { CapabilityDeniedCapability, CapabilityDeniedEvent, CommentsConfig, EditorCapabilities, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedMode, ExportCallOptions, ExportFormat, ExportFormatMap, InitOptions, ProjectEmbedMachine, UploadResult } from "./protocol.mjs";
|
|
3
3
|
import { AssetUploadAdapter, AssetUploadContext, AssetUploadRequest, CreateS3AssetUploadAdapterOptions, CreateSupabaseAssetUploadAdapterOptions, S3UploadTarget, SupabaseStorageClient, createS3AssetUploadAdapter, createSupabaseAssetUploadAdapter } from "./assetStorage.mjs";
|
|
4
|
+
import { i as getCredentialToken, n as StatelyCredential, r as createAuthorizationHeader, t as StatelyAuthMode } from "./auth-DO1-eQcU.mjs";
|
|
4
5
|
import { AssetConfig, StatelyEmbed, StatelyEmbedOptions, createStatelyEmbed } from "./embed.mjs";
|
|
5
|
-
import {
|
|
6
|
-
import { a as
|
|
6
|
+
import { _ as serializeJS, c as MachineConfigOptions, d as contextSchemaToTSType, f as eventsSchemaToTSType, g as raw, h as jsonSchemaToTSType, i as CodeGenGraph, l as RawCode, m as graphToXStateTS, o as GraphPatch, p as graphToMachineConfig, t as ActionLocation, u as XStateTSOptions } from "./index-BpUKBSiq.mjs";
|
|
7
|
+
import { C as EventTypeData, S as DigraphNodeConfig, _ as studioMachineConverter, a as StatelyGraphData, b as DigraphConfig, c as StatelyInvoke, d as StudioAction, f as StudioEdge, g as fromStudioMachine, h as StudioNode, i as StatelyGraph, l as StatelyNodeData, m as StudioMachine, o as StatelyGuard, r as StatelyEdgeData, t as StatelyAction, v as toStudioMachine, w as StateNodeJSONData, x as DigraphEdgeConfig, y as DigraphAction } from "./graph-Bm4_GZX_.mjs";
|
|
8
|
+
import { a as ManualActorOptions, c as createPostMessageTransport, i as InspectorEvents, l as createWebSocketTransport, n as CreateInspectorOptions, o as createStatelyInspector, r as Inspector, s as Transport, t as AdoptedActor } from "./inspect-BmZUcnZB.mjs";
|
|
7
9
|
import { ConnectedRepo, CreateMachineFromDefinitionInput, CreateMachineFromTemplateInput, CreateMachineInput, CreateMachineTemplate, CreateProjectInput, EnsureProjectInput, ExtractMachinesResponse, ExtractedMachine, GetMachineOptions, ProjectData, ProjectMachine, ProjectVisibility, RepoType, StudioApiError, StudioClient, StudioClientOptions, StudioMachineRecord, UpdateMachineInput, VerifyApiKeyResponse, XStateVersion, createStatelyClient } from "./studio.mjs";
|
|
10
|
+
import { OAuthAuthorizationServerMetadata, OAuthClientRegistrationResponse, OAuthProtectedResourceMetadata, OAuthTokenResponse, PkcePair, buildAuthorizeUrl, createPkcePair, discoverAuthorizationServer, discoverProtectedResource, exchangeCodeForToken, refreshToken, registerOAuthClient } from "./oauth.mjs";
|
|
8
11
|
import { PlanSyncOptions, PullSyncResult, PushLocalMachineLinksResult, PushSyncOptions, PushSyncProjectOptions, PushSyncResult, ResolvedSyncInput, SyncInputFormat, SyncPlan, SyncPlanSummary } from "./sync.mjs";
|
|
9
|
-
import { ActionLocation, GraphPatch } from "./patchTypes.mjs";
|
|
10
|
-
import { UnknownMachineConfig } from "xstate";
|
|
11
12
|
|
|
12
13
|
//#region src/statelyPragma.d.ts
|
|
13
14
|
interface StatelyPragma {
|
|
@@ -31,56 +32,4 @@ declare function findStatelyPragmaAttachments(sourceText: string, fileName?: str
|
|
|
31
32
|
declare function getStatelyPragma(sourceText: string, fileName?: string, machineIndex?: number): StatelyPragma | undefined;
|
|
32
33
|
declare function upsertStatelyPragma(sourceText: string, id: string, options?: UpsertStatelyPragmaOptions): string;
|
|
33
34
|
//#endregion
|
|
34
|
-
|
|
35
|
-
interface MachineConfigOptions {
|
|
36
|
-
showDescriptions?: boolean;
|
|
37
|
-
showMeta?: boolean;
|
|
38
|
-
/**
|
|
39
|
-
* Emit inline-code guards as a `{ type }` reference instead of an inline code
|
|
40
|
-
* expression directive. The simulation needs this: it can't evaluate guard
|
|
41
|
-
* source, so it stubs each guard by `type` (see getSimImplementations). A
|
|
42
|
-
* code-expression guard has no `type`, so XState reads `undefined` and throws
|
|
43
|
-
* "Guard 'undefined' is not implemented" the moment that transition is taken.
|
|
44
|
-
*/
|
|
45
|
-
inlineGuardsAsTypeRef?: boolean;
|
|
46
|
-
}
|
|
47
|
-
declare function graphToMachineConfig(graph: CodeGenGraph, options?: MachineConfigOptions): UnknownMachineConfig;
|
|
48
|
-
//#endregion
|
|
49
|
-
//#region src/graphToXStateTS.d.ts
|
|
50
|
-
interface XStateTSOptions extends MachineConfigOptions {
|
|
51
|
-
exportStyle?: 'named' | 'default' | 'none';
|
|
52
|
-
targetLanguage?: 'typescript' | 'javascript';
|
|
53
|
-
xstateVersion?: 5 | 6;
|
|
54
|
-
}
|
|
55
|
-
declare function graphToXStateTS(graph: CodeGenGraph, options?: XStateTSOptions): string;
|
|
56
|
-
//#endregion
|
|
57
|
-
//#region ../graph-tools/src/serializeJS.d.ts
|
|
58
|
-
/**
|
|
59
|
-
* Serializes JavaScript values as JS source code (not JSON).
|
|
60
|
-
* - Unquoted keys for valid identifiers
|
|
61
|
-
* - Single-quoted strings
|
|
62
|
-
* - Omits undefined values
|
|
63
|
-
* - Supports RawCode for verbatim expressions
|
|
64
|
-
* - Supports inline expression directives for verbatim expressions
|
|
65
|
-
*/
|
|
66
|
-
declare class RawCode {
|
|
67
|
-
code: string;
|
|
68
|
-
constructor(code: string);
|
|
69
|
-
}
|
|
70
|
-
declare function raw(code: string): RawCode;
|
|
71
|
-
declare function serializeJS(value: unknown, indent?: number, step?: number): string;
|
|
72
|
-
//#endregion
|
|
73
|
-
//#region src/jsonSchemaToTSType.d.ts
|
|
74
|
-
declare function jsonSchemaToTSType(schema: JSONSchema7 | undefined | null): string;
|
|
75
|
-
/**
|
|
76
|
-
* Build an inline context type string from the schemas.context record.
|
|
77
|
-
* Each key is a context property name, value is its JSONSchema7.
|
|
78
|
-
*/
|
|
79
|
-
declare function contextSchemaToTSType(context: Record<string, JSONSchema7> | null | undefined): string | null;
|
|
80
|
-
/**
|
|
81
|
-
* Build an event union type from the schemas.events record.
|
|
82
|
-
* Each key is the event type name, value describes the payload properties.
|
|
83
|
-
*/
|
|
84
|
-
declare function eventsSchemaToTSType(events: Record<string, JSONSchema7> | null | undefined): string | null;
|
|
85
|
-
//#endregion
|
|
86
|
-
export { type ActionLocation, type AdoptedActor, type AssetConfig, type AssetUploadAdapter, type AssetUploadContext, type AssetUploadRequest, type CodeGenGraph, type CommentsConfig, type ConnectedRepo, type CreateInspectorOptions, type CreateMachineFromDefinitionInput, type CreateMachineFromTemplateInput, type CreateMachineInput, type CreateMachineTemplate, type CreateProjectInput, type CreateS3AssetUploadAdapterOptions, type CreateSupabaseAssetUploadAdapterOptions, type DigraphAction, type DigraphConfig, type DigraphEdgeConfig, type DigraphNodeConfig, type EmbedEventHandler, type EmbedEventMap, type EmbedEventName, type EmbedMode, type EnsureProjectInput, type EventTypeData, type ExportCallOptions, type ExportFormat, type ExportFormatMap, type ExtractMachinesResponse, type ExtractedMachine, type GetMachineOptions, type GraphPatch, type InitOptions, type Inspector, type InspectorEvents, type MachineConfigOptions, type ManualActorOptions, type PlanSyncOptions, type ProjectData, type ProjectEmbedMachine, type ProjectMachine, type ProjectVisibility, type PullSyncResult, type PushLocalMachineLinksResult, type PushSyncOptions, type PushSyncProjectOptions, type PushSyncResult, RawCode, type RepoType, type ResolvedSyncInput, type S3UploadTarget, type StateNodeJSONData, type StatelyAction, type StatelyApiClientOptions, StatelyApiError, type StatelyApiUrlOptions, type StatelyEdgeData, type StatelyEmbed, type StatelyEmbedOptions, type StatelyGraph, type StatelyGraphData, type StatelyGuard, type StatelyInvoke, type StatelyNodeData, type StatelyPragma, type StatelyPragmaAttachment, type StudioAction, StudioApiError, type StudioClient, type StudioClientOptions, type StudioEdge, type StudioMachine, type StudioMachineRecord, type StudioNode, type SupabaseStorageClient, type SyncInputFormat, type SyncPlan, type SyncPlanSummary, type Transport, type UpdateMachineInput, type UploadResult, type UpsertStatelyPragmaOptions, type VerifyApiKeyResponse, type XStateTSOptions, type XStateVersion, contextSchemaToTSType, createPostMessageTransport, createS3AssetUploadAdapter, createStatelyApiClient, createStatelyApiUrl, createStatelyClient, createStatelyEmbed, createStatelyInspector, createSupabaseAssetUploadAdapter, createWebSocketTransport, eventsSchemaToTSType, findStatelyPragmaAttachments, fromStudioMachine, getStatelyPragma, graphToMachineConfig, graphToXStateTS, jsonSchemaToTSType, raw, serializeJS, studioMachineConverter, toStudioMachine, upsertStatelyPragma };
|
|
35
|
+
export { type ActionLocation, type AdoptedActor, type AssetConfig, type AssetUploadAdapter, type AssetUploadContext, type AssetUploadRequest, type CapabilityDeniedCapability, type CapabilityDeniedEvent, type CodeGenGraph, type CommentsConfig, type ConnectedRepo, type CreateInspectorOptions, type CreateMachineFromDefinitionInput, type CreateMachineFromTemplateInput, type CreateMachineInput, type CreateMachineTemplate, type CreateProjectInput, type CreateS3AssetUploadAdapterOptions, type CreateSupabaseAssetUploadAdapterOptions, type DigraphAction, type DigraphConfig, type DigraphEdgeConfig, type DigraphNodeConfig, type EditorCapabilities, type EmbedEventHandler, type EmbedEventMap, type EmbedEventName, type EmbedMode, type EnsureProjectInput, type EventTypeData, type ExportCallOptions, type ExportFormat, type ExportFormatMap, type ExtractMachinesResponse, type ExtractedMachine, type GetMachineOptions, type GraphPatch, type InitOptions, type Inspector, type InspectorEvents, type MachineConfigOptions, type ManualActorOptions, type OAuthAuthorizationServerMetadata, type OAuthClientRegistrationResponse, type OAuthProtectedResourceMetadata, type OAuthTokenResponse, type PkcePair, type PlanSyncOptions, type ProjectData, type ProjectEmbedMachine, type ProjectMachine, type ProjectVisibility, type PullSyncResult, type PushLocalMachineLinksResult, type PushSyncOptions, type PushSyncProjectOptions, type PushSyncResult, RawCode, type RepoType, type ResolvedSyncInput, type S3UploadTarget, type StateNodeJSONData, type StatelyAction, type StatelyApiClientOptions, StatelyApiError, type StatelyApiUrlOptions, type StatelyAuthMode, type StatelyCredential, type StatelyEdgeData, type StatelyEmbed, type StatelyEmbedOptions, type StatelyGraph, type StatelyGraphData, type StatelyGuard, type StatelyInvoke, type StatelyNodeData, type StatelyPragma, type StatelyPragmaAttachment, type StudioAction, StudioApiError, type StudioClient, type StudioClientOptions, type StudioEdge, type StudioMachine, type StudioMachineRecord, type StudioNode, type SupabaseStorageClient, type SyncInputFormat, type SyncPlan, type SyncPlanSummary, type Transport, type UpdateMachineInput, type UploadResult, type UpsertStatelyPragmaOptions, type VerifyApiKeyResponse, type XStateTSOptions, type XStateVersion, buildAuthorizeUrl, contextSchemaToTSType, createAuthorizationHeader, createPkcePair, createPostMessageTransport, createS3AssetUploadAdapter, createStatelyApiClient, createStatelyApiUrl, createStatelyClient, createStatelyEmbed, createStatelyInspector, createSupabaseAssetUploadAdapter, createWebSocketTransport, discoverAuthorizationServer, discoverProtectedResource, eventsSchemaToTSType, exchangeCodeForToken, findStatelyPragmaAttachments, fromStudioMachine, getCredentialToken, getStatelyPragma, graphToMachineConfig, graphToXStateTS, jsonSchemaToTSType, raw, refreshToken, registerOAuthClient, serializeJS, studioMachineConverter, toStudioMachine, upsertStatelyPragma };
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { n as createWebSocketTransport, t as createPostMessageTransport } from "./transport-
|
|
1
|
+
import { n as createWebSocketTransport, t as createPostMessageTransport } from "./transport-D0nlFaLn.mjs";
|
|
2
2
|
import { createStatelyEmbed } from "./embed.mjs";
|
|
3
3
|
import { createS3AssetUploadAdapter, createSupabaseAssetUploadAdapter } from "./assetStorage.mjs";
|
|
4
4
|
import { createStatelyInspector } from "./inspect.mjs";
|
|
5
|
+
import { createAuthorizationHeader, getCredentialToken } from "./auth.mjs";
|
|
5
6
|
import { StudioApiError, createStatelyClient } from "./studio.mjs";
|
|
7
|
+
import { buildAuthorizeUrl, createPkcePair, discoverAuthorizationServer, discoverProtectedResource, exchangeCodeForToken, refreshToken, registerOAuthClient } from "./oauth.mjs";
|
|
6
8
|
import { StatelyApiError, createStatelyApiClient, createStatelyApiUrl } from "./api.mjs";
|
|
7
|
-
import {
|
|
9
|
+
import { a as eventsSchemaToTSType, c as jsonSchemaToTSType, f as findStatelyPragmaAttachments, l as raw, m as upsertStatelyPragma, n as RawCode, o as graphToMachineConfig, p as getStatelyPragma, r as contextSchemaToTSType, s as graphToXStateTS, u as serializeJS } from "./dist-cQdIPK_n.mjs";
|
|
8
10
|
import { fromStudioMachine, studioMachineConverter, toStudioMachine } from "./graph.mjs";
|
|
9
11
|
|
|
10
|
-
export { RawCode, StatelyApiError, StudioApiError, contextSchemaToTSType, createPostMessageTransport, createS3AssetUploadAdapter, createStatelyApiClient, createStatelyApiUrl, createStatelyClient, createStatelyEmbed, createStatelyInspector, createSupabaseAssetUploadAdapter, createWebSocketTransport, eventsSchemaToTSType, findStatelyPragmaAttachments, fromStudioMachine, getStatelyPragma, graphToMachineConfig, graphToXStateTS, jsonSchemaToTSType, raw, serializeJS, studioMachineConverter, toStudioMachine, upsertStatelyPragma };
|
|
12
|
+
export { RawCode, StatelyApiError, StudioApiError, buildAuthorizeUrl, contextSchemaToTSType, createAuthorizationHeader, createPkcePair, createPostMessageTransport, createS3AssetUploadAdapter, createStatelyApiClient, createStatelyApiUrl, createStatelyClient, createStatelyEmbed, createStatelyInspector, createSupabaseAssetUploadAdapter, createWebSocketTransport, discoverAuthorizationServer, discoverProtectedResource, eventsSchemaToTSType, exchangeCodeForToken, findStatelyPragmaAttachments, fromStudioMachine, getCredentialToken, getStatelyPragma, graphToMachineConfig, graphToXStateTS, jsonSchemaToTSType, raw, refreshToken, registerOAuthClient, serializeJS, studioMachineConverter, toStudioMachine, upsertStatelyPragma };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EmbedEventMap, ExportCallOptions, ExportFormat, ExportFormatMap, ProtocolMessage } from "./protocol.mjs";
|
|
1
|
+
import { EditorCapabilities, EmbedEventMap, ExportCallOptions, ExportFormat, ExportFormatMap, ProtocolMessage } from "./protocol.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/transport.d.ts
|
|
4
4
|
interface Transport {
|
|
@@ -153,6 +153,7 @@ interface CreateInspectorOptions {
|
|
|
153
153
|
theme?: 'light' | 'dark';
|
|
154
154
|
readOnly?: boolean;
|
|
155
155
|
depth?: number;
|
|
156
|
+
capabilities?: EditorCapabilities;
|
|
156
157
|
/**
|
|
157
158
|
* Advanced: inject a pre-built transport (e.g. a channel from a
|
|
158
159
|
* multiplexed connection). When provided, `url`/`name` are ignored and the
|
package/dist/inspect.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedMode, ExportCallOptions, ExportFormat, ExportFormatMap } from "./protocol.mjs";
|
|
2
|
-
import { a as ManualActorOptions, i as InspectorEvents, n as CreateInspectorOptions, o as createStatelyInspector, r as Inspector, s as Transport, t as AdoptedActor } from "./inspect-
|
|
3
|
-
export { AdoptedActor, CreateInspectorOptions, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedMode, ExportCallOptions, ExportFormat, ExportFormatMap, Inspector, InspectorEvents, ManualActorOptions, Transport, createStatelyInspector };
|
|
1
|
+
import { EditorCapabilities, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedMode, ExportCallOptions, ExportFormat, ExportFormatMap } from "./protocol.mjs";
|
|
2
|
+
import { a as ManualActorOptions, i as InspectorEvents, n as CreateInspectorOptions, o as createStatelyInspector, r as Inspector, s as Transport, t as AdoptedActor } from "./inspect-BmZUcnZB.mjs";
|
|
3
|
+
export { AdoptedActor, CreateInspectorOptions, EditorCapabilities, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedMode, ExportCallOptions, ExportFormat, ExportFormatMap, Inspector, InspectorEvents, ManualActorOptions, Transport, createStatelyInspector };
|
package/dist/inspect.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as createPendingExportManager, n as createWebSocketTransport, r as createEventRegistry } from "./transport-
|
|
1
|
+
import { i as createPendingExportManager, n as createWebSocketTransport, r as createEventRegistry } from "./transport-D0nlFaLn.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/inspect.ts
|
|
4
4
|
const defaultSerializeSnapshot = (snapshot) => ({
|
|
@@ -11,7 +11,7 @@ function generateSessionId() {
|
|
|
11
11
|
return `manual-${Date.now()}-${nextManualId++}`;
|
|
12
12
|
}
|
|
13
13
|
function createStatelyInspector(options = {}) {
|
|
14
|
-
const { url = "ws://localhost:4242", autoOpen = true, name, serializeSnapshot = defaultSerializeSnapshot, extractMachineConfig = defaultExtractMachineConfig, selectedActorId, panels, theme, readOnly, depth, transport: injectedTransport } = options;
|
|
14
|
+
const { url = "ws://localhost:4242", autoOpen = true, name, serializeSnapshot = defaultSerializeSnapshot, extractMachineConfig = defaultExtractMachineConfig, selectedActorId, panels, theme, readOnly, depth, capabilities, transport: injectedTransport } = options;
|
|
15
15
|
const sessionId = options.sessionId ?? generateSessionId();
|
|
16
16
|
const displayName = name ?? "system:manual";
|
|
17
17
|
let destroyed = false;
|
|
@@ -134,6 +134,7 @@ function createStatelyInspector(options = {}) {
|
|
|
134
134
|
...theme && { theme },
|
|
135
135
|
...readOnly !== void 0 && { readOnly },
|
|
136
136
|
...depth !== void 0 && { depth },
|
|
137
|
+
...capabilities !== void 0 && { capabilities },
|
|
137
138
|
...panels?.leftPanels && { leftPanels: panels.leftPanels },
|
|
138
139
|
...panels?.rightPanels && { rightPanels: panels.rightPanels },
|
|
139
140
|
...panels?.activePanels && { activePanels: panels.activePanels }
|
package/dist/oauth.d.mts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
//#region src/oauth.d.ts
|
|
2
|
+
interface OAuthProtectedResourceMetadata {
|
|
3
|
+
resource: string;
|
|
4
|
+
authorization_servers?: string[];
|
|
5
|
+
bearer_methods_supported?: string[];
|
|
6
|
+
scopes_supported?: string[];
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
}
|
|
9
|
+
interface OAuthAuthorizationServerMetadata {
|
|
10
|
+
issuer: string;
|
|
11
|
+
authorization_endpoint?: string;
|
|
12
|
+
registration_endpoint?: string;
|
|
13
|
+
token_endpoint?: string;
|
|
14
|
+
code_challenge_methods_supported?: string[];
|
|
15
|
+
scopes_supported?: string[];
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
}
|
|
18
|
+
interface OAuthClientRegistrationResponse {
|
|
19
|
+
client_id: string;
|
|
20
|
+
client_id_issued_at?: number;
|
|
21
|
+
client_name?: string;
|
|
22
|
+
client_secret?: string;
|
|
23
|
+
client_secret_expires_at?: number;
|
|
24
|
+
redirect_uris?: string[];
|
|
25
|
+
[key: string]: unknown;
|
|
26
|
+
}
|
|
27
|
+
interface PkcePair {
|
|
28
|
+
codeVerifier: string;
|
|
29
|
+
codeChallenge: string;
|
|
30
|
+
}
|
|
31
|
+
interface OAuthTokenResponse {
|
|
32
|
+
access_token: string;
|
|
33
|
+
refresh_token?: string;
|
|
34
|
+
expires_in?: number;
|
|
35
|
+
expires_at?: number;
|
|
36
|
+
token_type?: string;
|
|
37
|
+
scope?: string;
|
|
38
|
+
[key: string]: unknown;
|
|
39
|
+
}
|
|
40
|
+
declare function discoverProtectedResource(resourceUrl: string | URL, options?: {
|
|
41
|
+
fetch?: typeof fetch;
|
|
42
|
+
}): Promise<OAuthProtectedResourceMetadata>;
|
|
43
|
+
declare function discoverAuthorizationServer(issuer: string | URL, options?: {
|
|
44
|
+
fetch?: typeof fetch;
|
|
45
|
+
}): Promise<OAuthAuthorizationServerMetadata>;
|
|
46
|
+
declare function registerOAuthClient(options: {
|
|
47
|
+
registrationEndpoint: string | URL;
|
|
48
|
+
redirectUri: string;
|
|
49
|
+
clientName?: string;
|
|
50
|
+
scopes?: string[];
|
|
51
|
+
fetch?: typeof fetch;
|
|
52
|
+
}): Promise<OAuthClientRegistrationResponse>;
|
|
53
|
+
declare function createPkcePair(): Promise<PkcePair>;
|
|
54
|
+
declare function buildAuthorizeUrl(options: {
|
|
55
|
+
authorizationEndpoint: string | URL;
|
|
56
|
+
clientId: string;
|
|
57
|
+
redirectUri: string;
|
|
58
|
+
codeChallenge: string;
|
|
59
|
+
state: string;
|
|
60
|
+
scopes?: string[];
|
|
61
|
+
}): string;
|
|
62
|
+
declare function exchangeCodeForToken(options: {
|
|
63
|
+
tokenEndpoint: string | URL;
|
|
64
|
+
code: string;
|
|
65
|
+
codeVerifier: string;
|
|
66
|
+
redirectUri: string;
|
|
67
|
+
clientId: string;
|
|
68
|
+
fetch?: typeof fetch;
|
|
69
|
+
}): Promise<OAuthTokenResponse>;
|
|
70
|
+
declare function refreshToken(options: {
|
|
71
|
+
tokenEndpoint: string | URL;
|
|
72
|
+
refreshToken: string;
|
|
73
|
+
clientId: string;
|
|
74
|
+
fetch?: typeof fetch;
|
|
75
|
+
}): Promise<OAuthTokenResponse>;
|
|
76
|
+
//#endregion
|
|
77
|
+
export { OAuthAuthorizationServerMetadata, OAuthClientRegistrationResponse, OAuthProtectedResourceMetadata, OAuthTokenResponse, PkcePair, buildAuthorizeUrl, createPkcePair, discoverAuthorizationServer, discoverProtectedResource, exchangeCodeForToken, refreshToken, registerOAuthClient };
|
package/dist/oauth.mjs
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
//#region src/oauth.ts
|
|
2
|
+
function getFetch(fetchImpl) {
|
|
3
|
+
const resolvedFetch = fetchImpl ?? globalThis.fetch;
|
|
4
|
+
if (!resolvedFetch) throw new Error("No fetch implementation available.");
|
|
5
|
+
return resolvedFetch;
|
|
6
|
+
}
|
|
7
|
+
async function fetchJson(url, fetchImpl) {
|
|
8
|
+
const response = await getFetch(fetchImpl)(url, { headers: { Accept: "application/json" } });
|
|
9
|
+
if (!response.ok) throw new Error(`${url} failed with HTTP ${response.status}`);
|
|
10
|
+
return response.json();
|
|
11
|
+
}
|
|
12
|
+
async function getOAuthResponseError(response) {
|
|
13
|
+
const detail = (await response.text().catch(() => "")).trim();
|
|
14
|
+
return detail ? `: ${detail}` : "";
|
|
15
|
+
}
|
|
16
|
+
async function discoverProtectedResource(resourceUrl, options = {}) {
|
|
17
|
+
const resource = new URL(String(resourceUrl));
|
|
18
|
+
const pathParts = resource.pathname.split("/").filter(Boolean);
|
|
19
|
+
const baseParts = pathParts.length > 2 && pathParts[0] !== "api" ? pathParts.slice(0, 1) : [];
|
|
20
|
+
const metadataUrl = new URL(resource.origin);
|
|
21
|
+
metadataUrl.pathname = [
|
|
22
|
+
...baseParts,
|
|
23
|
+
".well-known",
|
|
24
|
+
"oauth-protected-resource",
|
|
25
|
+
...pathParts
|
|
26
|
+
].join("/");
|
|
27
|
+
return fetchJson(metadataUrl.toString(), options.fetch);
|
|
28
|
+
}
|
|
29
|
+
async function discoverAuthorizationServer(issuer, options = {}) {
|
|
30
|
+
return fetchJson(getAuthorizationServerMetadataUrl(new URL(String(issuer))).toString(), options.fetch);
|
|
31
|
+
}
|
|
32
|
+
async function registerOAuthClient(options) {
|
|
33
|
+
const response = await getFetch(options.fetch)(String(options.registrationEndpoint), {
|
|
34
|
+
method: "POST",
|
|
35
|
+
headers: {
|
|
36
|
+
Accept: "application/json",
|
|
37
|
+
"Content-Type": "application/json"
|
|
38
|
+
},
|
|
39
|
+
body: JSON.stringify({
|
|
40
|
+
client_name: options.clientName ?? "Stately CLI",
|
|
41
|
+
redirect_uris: [options.redirectUri],
|
|
42
|
+
token_endpoint_auth_method: "none",
|
|
43
|
+
grant_types: ["authorization_code", "refresh_token"],
|
|
44
|
+
response_types: ["code"],
|
|
45
|
+
...options.scopes?.length ? { scope: options.scopes.join(" ") } : {}
|
|
46
|
+
})
|
|
47
|
+
});
|
|
48
|
+
if (!response.ok) throw new Error(`OAuth client registration failed with HTTP ${response.status}${await getOAuthResponseError(response)}`);
|
|
49
|
+
return response.json();
|
|
50
|
+
}
|
|
51
|
+
function getAuthorizationServerMetadataUrl(issuerUrl) {
|
|
52
|
+
const issuerPathParts = issuerUrl.pathname.split("/").filter(Boolean);
|
|
53
|
+
const oauthMetadataUrl = new URL(issuerUrl.origin);
|
|
54
|
+
oauthMetadataUrl.pathname = [
|
|
55
|
+
".well-known",
|
|
56
|
+
"oauth-authorization-server",
|
|
57
|
+
...issuerPathParts
|
|
58
|
+
].join("/");
|
|
59
|
+
return oauthMetadataUrl;
|
|
60
|
+
}
|
|
61
|
+
function base64UrlEncode(bytes) {
|
|
62
|
+
let binary = "";
|
|
63
|
+
for (const byte of bytes) binary += String.fromCharCode(byte);
|
|
64
|
+
return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
|
|
65
|
+
}
|
|
66
|
+
async function createPkcePair() {
|
|
67
|
+
const verifierBytes = new Uint8Array(32);
|
|
68
|
+
crypto.getRandomValues(verifierBytes);
|
|
69
|
+
const codeVerifier = base64UrlEncode(verifierBytes);
|
|
70
|
+
return {
|
|
71
|
+
codeVerifier,
|
|
72
|
+
codeChallenge: base64UrlEncode(new Uint8Array(await crypto.subtle.digest("SHA-256", new TextEncoder().encode(codeVerifier))))
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function buildAuthorizeUrl(options) {
|
|
76
|
+
const url = new URL(String(options.authorizationEndpoint));
|
|
77
|
+
url.searchParams.set("response_type", "code");
|
|
78
|
+
url.searchParams.set("client_id", options.clientId);
|
|
79
|
+
url.searchParams.set("redirect_uri", options.redirectUri);
|
|
80
|
+
url.searchParams.set("code_challenge", options.codeChallenge);
|
|
81
|
+
url.searchParams.set("code_challenge_method", "S256");
|
|
82
|
+
url.searchParams.set("state", options.state);
|
|
83
|
+
if (options.scopes?.length) url.searchParams.set("scope", options.scopes.join(" "));
|
|
84
|
+
return url.toString();
|
|
85
|
+
}
|
|
86
|
+
async function exchangeCodeForToken(options) {
|
|
87
|
+
const body = new URLSearchParams({
|
|
88
|
+
grant_type: "authorization_code",
|
|
89
|
+
code: options.code,
|
|
90
|
+
code_verifier: options.codeVerifier,
|
|
91
|
+
redirect_uri: options.redirectUri,
|
|
92
|
+
client_id: options.clientId
|
|
93
|
+
});
|
|
94
|
+
const response = await getFetch(options.fetch)(String(options.tokenEndpoint), {
|
|
95
|
+
method: "POST",
|
|
96
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
97
|
+
body
|
|
98
|
+
});
|
|
99
|
+
if (!response.ok) throw new Error(`Token exchange failed with HTTP ${response.status}${await getOAuthResponseError(response)}`);
|
|
100
|
+
return response.json();
|
|
101
|
+
}
|
|
102
|
+
async function refreshToken(options) {
|
|
103
|
+
const body = new URLSearchParams({
|
|
104
|
+
grant_type: "refresh_token",
|
|
105
|
+
refresh_token: options.refreshToken,
|
|
106
|
+
client_id: options.clientId
|
|
107
|
+
});
|
|
108
|
+
const response = await getFetch(options.fetch)(String(options.tokenEndpoint), {
|
|
109
|
+
method: "POST",
|
|
110
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
111
|
+
body
|
|
112
|
+
});
|
|
113
|
+
if (!response.ok) throw new Error(`Token refresh failed with HTTP ${response.status}${await getOAuthResponseError(response)}`);
|
|
114
|
+
return response.json();
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
//#endregion
|
|
118
|
+
export { buildAuthorizeUrl, createPkcePair, discoverAuthorizationServer, discoverProtectedResource, exchangeCodeForToken, refreshToken, registerOAuthClient };
|
package/dist/patchTypes.d.mts
CHANGED
|
@@ -1,249 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
type
|
|
3
|
-
type CanvasColor = 'green' | 'red' | 'purple' | 'blue' | 'orange' | 'yellow' | 'pink' | 'teal';
|
|
4
|
-
type ActionLocation = {
|
|
5
|
-
nodeId: string;
|
|
6
|
-
group: 'entry' | 'exit';
|
|
7
|
-
} | {
|
|
8
|
-
edgeId: string;
|
|
9
|
-
group: 'transition';
|
|
10
|
-
};
|
|
11
|
-
type ImplementationSourceType = 'action' | 'guard' | 'actor' | 'delay';
|
|
12
|
-
type GraphPatch = {
|
|
13
|
-
op: 'createNode';
|
|
14
|
-
description?: string;
|
|
15
|
-
id?: string;
|
|
16
|
-
parentId: string;
|
|
17
|
-
key: string;
|
|
18
|
-
type?: EditorStateType;
|
|
19
|
-
x?: number;
|
|
20
|
-
y?: number;
|
|
21
|
-
} | {
|
|
22
|
-
op: 'updateNode';
|
|
23
|
-
description?: string;
|
|
24
|
-
nodeId: string;
|
|
25
|
-
data: {
|
|
26
|
-
key?: string;
|
|
27
|
-
type?: EditorStateType;
|
|
28
|
-
description?: string;
|
|
29
|
-
initialId?: string | null;
|
|
30
|
-
};
|
|
31
|
-
} | {
|
|
32
|
-
op: 'deleteNode';
|
|
33
|
-
description?: string;
|
|
34
|
-
nodeId: string;
|
|
35
|
-
} | {
|
|
36
|
-
op: 'createEdge';
|
|
37
|
-
description?: string;
|
|
38
|
-
id?: string;
|
|
39
|
-
sourceId: string;
|
|
40
|
-
targetId: string;
|
|
41
|
-
eventType: string;
|
|
42
|
-
transitionType?: 'normal' | 'targetless' | 'reenter';
|
|
43
|
-
} | {
|
|
44
|
-
op: 'updateEdge';
|
|
45
|
-
description?: string;
|
|
46
|
-
edgeId: string;
|
|
47
|
-
data: {
|
|
48
|
-
sourceId?: string;
|
|
49
|
-
targetId?: string;
|
|
50
|
-
eventType?: string;
|
|
51
|
-
transitionType?: 'normal' | 'targetless' | 'reenter';
|
|
52
|
-
description?: string | null;
|
|
53
|
-
};
|
|
54
|
-
} | {
|
|
55
|
-
op: 'deleteEdge';
|
|
56
|
-
description?: string;
|
|
57
|
-
edgeId: string;
|
|
58
|
-
} | {
|
|
59
|
-
op: 'createState';
|
|
60
|
-
description?: string;
|
|
61
|
-
id?: string;
|
|
62
|
-
parentId: string;
|
|
63
|
-
key: string;
|
|
64
|
-
type?: EditorStateType;
|
|
65
|
-
x?: number;
|
|
66
|
-
y?: number;
|
|
67
|
-
color?: CanvasColor | null;
|
|
68
|
-
initial?: boolean;
|
|
69
|
-
} | {
|
|
70
|
-
op: 'updateState';
|
|
71
|
-
description?: string;
|
|
72
|
-
stateId: string;
|
|
73
|
-
key?: string;
|
|
74
|
-
type?: EditorStateType;
|
|
75
|
-
stateDescription?: string;
|
|
76
|
-
initialId?: string | null;
|
|
77
|
-
color?: CanvasColor | null;
|
|
78
|
-
meta?: Record<string, unknown> | null;
|
|
79
|
-
history?: 'shallow' | 'deep' | null;
|
|
80
|
-
} | {
|
|
81
|
-
op: 'deleteState';
|
|
82
|
-
description?: string;
|
|
83
|
-
stateId: string;
|
|
84
|
-
} | {
|
|
85
|
-
op: 'createTransition';
|
|
86
|
-
description?: string;
|
|
87
|
-
id?: string;
|
|
88
|
-
sourceId: string;
|
|
89
|
-
targetId: string;
|
|
90
|
-
eventType: string;
|
|
91
|
-
transitionType?: 'normal' | 'targetless' | 'reenter';
|
|
92
|
-
guard?: {
|
|
93
|
-
type: string;
|
|
94
|
-
code?: string;
|
|
95
|
-
params?: Record<string, unknown>;
|
|
96
|
-
};
|
|
97
|
-
color?: CanvasColor | null;
|
|
98
|
-
transitionDescription?: string | null;
|
|
99
|
-
} | {
|
|
100
|
-
op: 'updateTransition';
|
|
101
|
-
description?: string;
|
|
102
|
-
transitionId: string;
|
|
103
|
-
sourceId?: string;
|
|
104
|
-
targetId?: string;
|
|
105
|
-
eventType?: string;
|
|
106
|
-
transitionType?: 'normal' | 'targetless' | 'reenter';
|
|
107
|
-
transitionDescription?: string | null;
|
|
108
|
-
color?: CanvasColor | null;
|
|
109
|
-
meta?: Record<string, unknown> | null;
|
|
110
|
-
} | {
|
|
111
|
-
op: 'deleteTransition';
|
|
112
|
-
description?: string;
|
|
113
|
-
transitionId: string;
|
|
114
|
-
} | {
|
|
115
|
-
op: 'createAction';
|
|
116
|
-
description?: string;
|
|
117
|
-
location: ActionLocation;
|
|
118
|
-
action: {
|
|
119
|
-
id?: string;
|
|
120
|
-
type: string;
|
|
121
|
-
params?: Record<string, unknown>;
|
|
122
|
-
code?: string;
|
|
123
|
-
};
|
|
124
|
-
index?: number;
|
|
125
|
-
} | {
|
|
126
|
-
op: 'updateAction';
|
|
127
|
-
description?: string;
|
|
128
|
-
location: ActionLocation;
|
|
129
|
-
actionId: string;
|
|
130
|
-
data: {
|
|
131
|
-
type?: string;
|
|
132
|
-
params?: Record<string, unknown>;
|
|
133
|
-
code?: string;
|
|
134
|
-
};
|
|
135
|
-
} | {
|
|
136
|
-
op: 'deleteAction';
|
|
137
|
-
description?: string;
|
|
138
|
-
location: ActionLocation;
|
|
139
|
-
actionId: string;
|
|
140
|
-
} | {
|
|
141
|
-
op: 'createInvoke';
|
|
142
|
-
description?: string;
|
|
143
|
-
nodeId: string;
|
|
144
|
-
invoke: {
|
|
145
|
-
id?: string;
|
|
146
|
-
src: string;
|
|
147
|
-
code?: string;
|
|
148
|
-
input?: Record<string, unknown>;
|
|
149
|
-
output?: Record<string, unknown>;
|
|
150
|
-
};
|
|
151
|
-
} | {
|
|
152
|
-
op: 'updateInvoke';
|
|
153
|
-
description?: string;
|
|
154
|
-
nodeId: string;
|
|
155
|
-
invokeId: string;
|
|
156
|
-
data: {
|
|
157
|
-
src?: string;
|
|
158
|
-
code?: string;
|
|
159
|
-
input?: Record<string, unknown>;
|
|
160
|
-
output?: Record<string, unknown>;
|
|
161
|
-
};
|
|
162
|
-
} | {
|
|
163
|
-
op: 'deleteInvoke';
|
|
164
|
-
description?: string;
|
|
165
|
-
nodeId: string;
|
|
166
|
-
invokeId: string;
|
|
167
|
-
} | {
|
|
168
|
-
op: 'createImplementation';
|
|
169
|
-
description?: string;
|
|
170
|
-
sourceType: ImplementationSourceType;
|
|
171
|
-
implementation: {
|
|
172
|
-
id: string;
|
|
173
|
-
name?: string;
|
|
174
|
-
code?: string;
|
|
175
|
-
};
|
|
176
|
-
} | {
|
|
177
|
-
op: 'updateImplementation';
|
|
178
|
-
description?: string;
|
|
179
|
-
sourceType: ImplementationSourceType;
|
|
180
|
-
implementationId: string;
|
|
181
|
-
data: {
|
|
182
|
-
name?: string;
|
|
183
|
-
code?: string;
|
|
184
|
-
};
|
|
185
|
-
} | {
|
|
186
|
-
op: 'deleteImplementation';
|
|
187
|
-
description?: string;
|
|
188
|
-
sourceType: ImplementationSourceType;
|
|
189
|
-
implementationId: string;
|
|
190
|
-
} | {
|
|
191
|
-
op: 'setGuard';
|
|
192
|
-
description?: string;
|
|
193
|
-
edgeId: string;
|
|
194
|
-
guard: {
|
|
195
|
-
type: string;
|
|
196
|
-
code?: string;
|
|
197
|
-
params?: Record<string, unknown>;
|
|
198
|
-
};
|
|
199
|
-
} | {
|
|
200
|
-
op: 'deleteGuard';
|
|
201
|
-
description?: string;
|
|
202
|
-
edgeId: string;
|
|
203
|
-
} | {
|
|
204
|
-
op: 'createTag';
|
|
205
|
-
description?: string;
|
|
206
|
-
nodeId: string;
|
|
207
|
-
tag: {
|
|
208
|
-
name: string;
|
|
209
|
-
};
|
|
210
|
-
} | {
|
|
211
|
-
op: 'deleteTag';
|
|
212
|
-
description?: string;
|
|
213
|
-
nodeId: string;
|
|
214
|
-
tagName: string;
|
|
215
|
-
} | {
|
|
216
|
-
op: 'createAnnotation';
|
|
217
|
-
description?: string;
|
|
218
|
-
id?: string;
|
|
219
|
-
parentId: string | null;
|
|
220
|
-
content: string;
|
|
221
|
-
x?: number;
|
|
222
|
-
y?: number;
|
|
223
|
-
} | {
|
|
224
|
-
op: 'updateAnnotation';
|
|
225
|
-
description?: string;
|
|
226
|
-
annotationId: string;
|
|
227
|
-
data: {
|
|
228
|
-
content?: string;
|
|
229
|
-
};
|
|
230
|
-
} | {
|
|
231
|
-
op: 'deleteAnnotation';
|
|
232
|
-
description?: string;
|
|
233
|
-
annotationId: string;
|
|
234
|
-
} | {
|
|
235
|
-
op: 'setContext';
|
|
236
|
-
description?: string;
|
|
237
|
-
context: Record<string, unknown>;
|
|
238
|
-
} | {
|
|
239
|
-
op: 'updateSchemas';
|
|
240
|
-
description?: string;
|
|
241
|
-
schemas: {
|
|
242
|
-
context?: Record<string, unknown> | null;
|
|
243
|
-
events?: Record<string, unknown> | null;
|
|
244
|
-
input?: unknown | null;
|
|
245
|
-
output?: unknown | null;
|
|
246
|
-
};
|
|
247
|
-
};
|
|
248
|
-
//#endregion
|
|
249
|
-
export { ActionLocation, CanvasColor, EditorStateType, GraphPatch, ImplementationSourceType };
|
|
1
|
+
import { a as EditorStateType, n as CanvasColor, o as GraphPatch, s as ImplementationSourceType, t as ActionLocation } from "./index-BpUKBSiq.mjs";
|
|
2
|
+
export { type ActionLocation, type CanvasColor, type EditorStateType, type GraphPatch, type ImplementationSourceType };
|