@party-stack/connect 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +189 -2
- package/lib/ServiceConnector.d.ts +68 -0
- package/lib/ServiceConnector.d.ts.map +1 -0
- package/lib/ServiceConnector.js +1 -0
- package/lib/acquireConfiguredConnection.d.ts +32 -0
- package/lib/acquireConfiguredConnection.d.ts.map +1 -0
- package/lib/acquireConfiguredConnection.js +54 -0
- package/lib/acquireConfiguredConnection.js.map +1 -0
- package/lib/authentication.d.ts +76 -0
- package/lib/authentication.d.ts.map +1 -0
- package/lib/authentication.js +95 -0
- package/lib/authentication.js.map +1 -0
- package/lib/authorization.d.ts +43 -0
- package/lib/authorization.d.ts.map +1 -0
- package/lib/authorization.js +175 -0
- package/lib/authorization.js.map +1 -0
- package/lib/core/accessToken.d.ts +10 -0
- package/lib/core/accessToken.d.ts.map +1 -0
- package/lib/core/accessToken.js +87 -0
- package/lib/core/accessToken.js.map +1 -0
- package/lib/core/backend.d.ts +33 -0
- package/lib/core/backend.d.ts.map +1 -0
- package/lib/core/backend.js +249 -0
- package/lib/core/backend.js.map +1 -0
- package/lib/core/errors.d.ts +13 -0
- package/lib/core/errors.d.ts.map +1 -0
- package/lib/core/errors.js +26 -0
- package/lib/core/errors.js.map +1 -0
- package/lib/core/maintenance.d.ts +11 -0
- package/lib/core/maintenance.d.ts.map +1 -0
- package/lib/core/maintenance.js +21 -0
- package/lib/core/maintenance.js.map +1 -0
- package/lib/core/migrate.d.ts +18 -0
- package/lib/core/migrate.d.ts.map +1 -0
- package/lib/core/migrate.js +71 -0
- package/lib/core/migrate.js.map +1 -0
- package/lib/core/oauth.d.ts +27 -0
- package/lib/core/oauth.d.ts.map +1 -0
- package/lib/core/oauth.js +82 -0
- package/lib/core/oauth.js.map +1 -0
- package/lib/core/oauthAuthority.d.ts +90 -0
- package/lib/core/oauthAuthority.d.ts.map +1 -0
- package/lib/core/oauthAuthority.js +382 -0
- package/lib/core/oauthAuthority.js.map +1 -0
- package/lib/core/store.d.ts +48 -0
- package/lib/core/store.d.ts.map +1 -0
- package/lib/core/store.js +92 -0
- package/lib/core/store.js.map +1 -0
- package/lib/createDefaultConnectionEgressHandlers.d.ts +5 -0
- package/lib/createDefaultConnectionEgressHandlers.d.ts.map +1 -0
- package/lib/createDefaultConnectionEgressHandlers.js +20 -0
- package/lib/createDefaultConnectionEgressHandlers.js.map +1 -0
- package/lib/index.d.ts +20 -0
- package/lib/index.js +17 -0
- package/lib/makeConnectManager.d.ts +90 -0
- package/lib/makeConnectManager.d.ts.map +1 -0
- package/lib/makeConnectManager.js +91 -0
- package/lib/makeConnectManager.js.map +1 -0
- package/lib/oauth/storage.d.ts +9 -0
- package/lib/oauth/storage.d.ts.map +1 -0
- package/lib/oauth/storage.js +16 -0
- package/lib/oauth/storage.js.map +1 -0
- package/lib/publicOntology.d.ts +17 -0
- package/lib/publicOntology.d.ts.map +1 -0
- package/lib/publicOntology.js +86 -0
- package/lib/publicOntology.js.map +1 -0
- package/lib/server/index.d.ts +33 -0
- package/lib/server/index.d.ts.map +1 -0
- package/lib/server/index.js +119 -0
- package/lib/server/index.js.map +1 -0
- package/lib/serverClient.d.ts +28 -0
- package/lib/serverClient.d.ts.map +1 -0
- package/lib/serverClient.js +67 -0
- package/lib/serverClient.js.map +1 -0
- package/lib/serviceConnections.d.ts +39 -0
- package/lib/serviceConnections.d.ts.map +1 -0
- package/lib/serviceConnections.js +277 -0
- package/lib/serviceConnections.js.map +1 -0
- package/lib/spec/index.d.ts +958 -0
- package/lib/spec/index.d.ts.map +1 -0
- package/lib/spec/index.js +565 -0
- package/lib/spec/index.js.map +1 -0
- package/lib/toWebEgress.d.ts +12 -0
- package/lib/toWebEgress.d.ts.map +1 -0
- package/lib/toWebEgress.js +28 -0
- package/lib/toWebEgress.js.map +1 -0
- package/lib/types.d.ts +44 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +25 -0
- package/lib/types.js.map +1 -0
- package/lib/withHttpAuthenticationErrors.d.ts +5 -0
- package/lib/withHttpAuthenticationErrors.d.ts.map +1 -0
- package/lib/withHttpAuthenticationErrors.js +20 -0
- package/lib/withHttpAuthenticationErrors.js.map +1 -0
- package/package.json +34 -3
package/lib/types.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { BackendError } from "@party-stack/ontology-backend";
|
|
2
|
+
import { Effect, Schema, Stream } from "effect";
|
|
3
|
+
//#region src/types.d.ts
|
|
4
|
+
export declare const ConnectionStateSchema: Schema.Union<readonly [Schema.Struct<{
|
|
5
|
+
readonly status: Schema.Literal<"pending">;
|
|
6
|
+
}>, Schema.Struct<{
|
|
7
|
+
readonly status: Schema.Literal<"active">;
|
|
8
|
+
readonly expiration: Schema.optional<Schema.Struct<{
|
|
9
|
+
readonly expiresAt: Schema.Number;
|
|
10
|
+
readonly refreshable: Schema.Boolean;
|
|
11
|
+
}>>;
|
|
12
|
+
}>, Schema.Struct<{
|
|
13
|
+
readonly status: Schema.Literal<"inactive">;
|
|
14
|
+
}>, Schema.Struct<{
|
|
15
|
+
readonly status: Schema.Literal<"needs-auth">;
|
|
16
|
+
readonly error: Schema.optional<Schema.String>;
|
|
17
|
+
}>, Schema.Struct<{
|
|
18
|
+
readonly status: Schema.Literal<"error">;
|
|
19
|
+
readonly error: Schema.String;
|
|
20
|
+
}>]>;
|
|
21
|
+
export type ConnectionState = typeof ConnectionStateSchema.Type;
|
|
22
|
+
export type ConnectionStatus = ConnectionState["status"];
|
|
23
|
+
export interface ConnectionEgressHandlers {
|
|
24
|
+
fetch(request: Request): Effect.Effect<Response, BackendError>;
|
|
25
|
+
createWebSocket(url: string | URL, protocols?: string | string[]): Effect.Effect<WebSocket, BackendError>;
|
|
26
|
+
}
|
|
27
|
+
export interface ConnectionEgress {
|
|
28
|
+
fetch(input: RequestInfo | URL, init?: RequestInit): Effect.Effect<Response, BackendError>;
|
|
29
|
+
createWebSocket(url: string | URL, protocols?: string | string[]): Effect.Effect<WebSocket, BackendError>;
|
|
30
|
+
}
|
|
31
|
+
/** Serializable, reactive connection metadata and lifecycle state. */
|
|
32
|
+
export interface Connection<Status extends ConnectionStatus = ConnectionStatus> {
|
|
33
|
+
userId: string;
|
|
34
|
+
state: ConnectionState & {
|
|
35
|
+
status: Status;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export interface ConnectionMonitor {
|
|
39
|
+
readonly state: ConnectionState;
|
|
40
|
+
/** Includes the current state, followed by connection lifecycle changes. */
|
|
41
|
+
readonly changes: Stream.Stream<ConnectionState>;
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../src/types.ts"],"mappings":";;;qBAKa,uBAAqB,OAAA,gBAAA,OAAA;;;;;;;;;;;;;;;;;YAUtB,yBAAyB,sBAAsB;YAE/C,mBAAmB;iBAEd;EACb,MAAM,SAAS,UAAU,OAAO,OAAO,UAAU;EACjD,gBAAgB,cAAc,KAAK,gCAAgC,OAAO,OAAO,WAAW;;iBAG/E;EACb,MAAM,OAAO,cAAc,KAAK,OAAO,cAAc,OAAO,OAAO,UAAU;EAC7E,gBAAgB,cAAc,KAAK,gCAAgC,OAAO,OAAO,WAAW;;;iBAI/E,WAAW,eAAe,mBAAmB;EAC1D;EACA,OAAO;IAAoB,QAAQ;;;iBAGtB;WACJ,OAAO;;WAEP,SAAS,OAAO,OAAO"}
|
package/lib/types.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
//#region src/types.ts
|
|
3
|
+
const ConnectionStateSchema = Schema.Union([
|
|
4
|
+
Schema.Struct({ status: Schema.Literal("pending") }),
|
|
5
|
+
Schema.Struct({
|
|
6
|
+
status: Schema.Literal("active"),
|
|
7
|
+
expiration: Schema.optional(Schema.Struct({
|
|
8
|
+
expiresAt: Schema.Number,
|
|
9
|
+
refreshable: Schema.Boolean
|
|
10
|
+
}))
|
|
11
|
+
}),
|
|
12
|
+
Schema.Struct({ status: Schema.Literal("inactive") }),
|
|
13
|
+
Schema.Struct({
|
|
14
|
+
status: Schema.Literal("needs-auth"),
|
|
15
|
+
error: Schema.optional(Schema.String)
|
|
16
|
+
}),
|
|
17
|
+
Schema.Struct({
|
|
18
|
+
status: Schema.Literal("error"),
|
|
19
|
+
error: Schema.String
|
|
20
|
+
})
|
|
21
|
+
]);
|
|
22
|
+
//#endregion
|
|
23
|
+
export { ConnectionStateSchema };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=types.js.map
|
package/lib/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["import { Schema } from \"effect\";\nimport type { BackendError } from \"@party-stack/ontology-backend\";\nimport type { Stream } from \"effect\";\nimport type { Effect } from \"effect\";\n\nexport const ConnectionStateSchema = Schema.Union([\n Schema.Struct({ status: Schema.Literal(\"pending\") }),\n Schema.Struct({\n status: Schema.Literal(\"active\"),\n expiration: Schema.optional(Schema.Struct({ expiresAt: Schema.Number, refreshable: Schema.Boolean })),\n }),\n Schema.Struct({ status: Schema.Literal(\"inactive\") }),\n Schema.Struct({ status: Schema.Literal(\"needs-auth\"), error: Schema.optional(Schema.String) }),\n Schema.Struct({ status: Schema.Literal(\"error\"), error: Schema.String }),\n]);\nexport type ConnectionState = typeof ConnectionStateSchema.Type;\n\nexport type ConnectionStatus = ConnectionState[\"status\"];\n\nexport interface ConnectionEgressHandlers {\n fetch(request: Request): Effect.Effect<Response, BackendError>;\n createWebSocket(url: string | URL, protocols?: string | string[]): Effect.Effect<WebSocket, BackendError>;\n}\n\nexport interface ConnectionEgress {\n fetch(input: RequestInfo | URL, init?: RequestInit): Effect.Effect<Response, BackendError>;\n createWebSocket(url: string | URL, protocols?: string | string[]): Effect.Effect<WebSocket, BackendError>;\n}\n\n/** Serializable, reactive connection metadata and lifecycle state. */\nexport interface Connection<Status extends ConnectionStatus = ConnectionStatus> {\n userId: string;\n state: ConnectionState & { status: Status };\n}\n\nexport interface ConnectionMonitor {\n readonly state: ConnectionState;\n /** Includes the current state, followed by connection lifecycle changes. */\n readonly changes: Stream.Stream<ConnectionState>;\n}\n"],"mappings":";;AAKA,MAAa,wBAAwB,OAAO,MAAM;CAC9C,OAAO,OAAO,EAAE,QAAQ,OAAO,QAAQ,SAAS,EAAE,CAAC;CACnD,OAAO,OAAO;EACV,QAAQ,OAAO,QAAQ,QAAQ;EAC/B,YAAY,OAAO,SAAS,OAAO,OAAO;GAAE,WAAW,OAAO;GAAQ,aAAa,OAAO;EAAQ,CAAC,CAAC;CACxG,CAAC;CACD,OAAO,OAAO,EAAE,QAAQ,OAAO,QAAQ,UAAU,EAAE,CAAC;CACpD,OAAO,OAAO;EAAE,QAAQ,OAAO,QAAQ,YAAY;EAAG,OAAO,OAAO,SAAS,OAAO,MAAM;CAAE,CAAC;CAC7F,OAAO,OAAO;EAAE,QAAQ,OAAO,QAAQ,OAAO;EAAG,OAAO,OAAO;CAAO,CAAC;AAC3E,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ConnectionEgressHandlers } from "./types.js";
|
|
2
|
+
//#region src/withHttpAuthenticationErrors.d.ts
|
|
3
|
+
export declare function withHttpAuthenticationErrors(handlers: ConnectionEgressHandlers): ConnectionEgressHandlers;
|
|
4
|
+
//#endregion
|
|
5
|
+
//# sourceMappingURL=withHttpAuthenticationErrors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withHttpAuthenticationErrors.d.ts","names":[],"sources":["../src/withHttpAuthenticationErrors.ts"],"mappings":";;wBAIgB,6BAA6B,UAAU,2BAA2B"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { unauthenticated } from "@party-stack/ontology-backend";
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
//#region src/withHttpAuthenticationErrors.ts
|
|
4
|
+
function withHttpAuthenticationErrors(handlers) {
|
|
5
|
+
return {
|
|
6
|
+
...handlers,
|
|
7
|
+
fetch: Effect.fnUntraced(function* (request) {
|
|
8
|
+
const response = yield* handlers.fetch(request);
|
|
9
|
+
if (response.status === 401) {
|
|
10
|
+
if (response.body) yield* Effect.promise(() => response.body.cancel()).pipe(Effect.ignoreCause);
|
|
11
|
+
return yield* unauthenticated("Request failed with status 401.");
|
|
12
|
+
}
|
|
13
|
+
return response;
|
|
14
|
+
})
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { withHttpAuthenticationErrors };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=withHttpAuthenticationErrors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withHttpAuthenticationErrors.js","names":[],"sources":["../src/withHttpAuthenticationErrors.ts"],"sourcesContent":["import { unauthenticated } from \"@party-stack/ontology-backend\";\nimport { Effect } from \"effect\";\nimport type { ConnectionEgressHandlers } from \"./types.js\";\n\nexport function withHttpAuthenticationErrors(handlers: ConnectionEgressHandlers): ConnectionEgressHandlers {\n return {\n ...handlers,\n fetch: Effect.fnUntraced(function* (request: Request) {\n const response = yield* handlers.fetch(request);\n if (response.status === 401) {\n if (response.body)\n yield* Effect.promise(() => response.body!.cancel()).pipe(Effect.ignoreCause);\n return yield* unauthenticated(\"Request failed with status 401.\");\n }\n return response;\n }),\n };\n}\n"],"mappings":";;;AAIA,SAAgB,6BAA6B,UAA8D;CACvG,OAAO;EACH,GAAG;EACH,OAAO,OAAO,WAAW,WAAW,SAAkB;GAClD,MAAM,WAAW,OAAO,SAAS,MAAM,OAAO;GAC9C,IAAI,SAAS,WAAW,KAAK;IACzB,IAAI,SAAS,MACT,OAAO,OAAO,cAAc,SAAS,KAAM,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,WAAW;IAChF,OAAO,OAAO,gBAAgB,iCAAiC;GACnE;GACA,OAAO;EACX,CAAC;CACL;AACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@party-stack/connect",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"files": [
|
|
5
|
+
"lib"
|
|
6
|
+
],
|
|
7
|
+
"type": "module",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./lib/index.d.ts",
|
|
11
|
+
"default": "./lib/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./spec": {
|
|
14
|
+
"types": "./lib/spec/index.d.ts",
|
|
15
|
+
"default": "./lib/spec/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./server": {
|
|
18
|
+
"types": "./lib/server/index.d.ts",
|
|
19
|
+
"default": "./lib/server/index.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"effect": "^4.0.5",
|
|
24
|
+
"oauth4webapi": "^3.8.7",
|
|
25
|
+
"temporal-polyfill": "^0.3.0",
|
|
26
|
+
"@party-stack/ontology-backend": "0.2.1",
|
|
27
|
+
"@party-stack/ontology-spec": "0.3.0",
|
|
28
|
+
"@party-stack/ontology-storage": "0.2.1",
|
|
29
|
+
"@party-stack/runtime": "0.5.1"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"typescript": "~7.0.2",
|
|
33
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@1.2.0",
|
|
34
|
+
"vite-plus": "1.2.0",
|
|
35
|
+
"@party-stack/build-config": "0.2.0"
|
|
36
|
+
}
|
|
6
37
|
}
|