@samebase/alchemy-convex 0.46.0 → 0.47.0

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.
@@ -1,162 +0,0 @@
1
- import { t as Providers } from "./Providers-zL1fUs0r.js";
2
- import { Stack } from "alchemy/Stack";
3
- import * as Effect from "effect/Effect";
4
- import * as Schema from "effect/Schema";
5
- import * as Redacted from "effect/Redacted";
6
- import { Resource } from "alchemy";
7
- import * as Provider from "alchemy/Provider";
8
- import { Random } from "alchemy/Random";
9
- import * as Output from "alchemy/Output";
10
- import { State } from "alchemy/State";
11
- //#region src/IdentityBroker.d.ts
12
- /** The client ID and the client secret of a deployment without a broker client. */
13
- export declare const DISABLED = "broker-disabled";
14
- /**
15
- * The app's default name: the stack's path below `owner/repo`, or `app` for a stack named after
16
- * the repository. Undefined for a stack whose name is not `owner/repo` or `owner/repo/<path>`.
17
- */
18
- export declare const defaultApp: (stackName: string) => string | undefined;
19
- /**
20
- * An identity broker of @samebase/identity-broker, such as Samebase's public broker:
21
- * `{ issuer: "https://id.samebase.com" }`.
22
- */
23
- export interface BrokerEndpoint {
24
- /**
25
- * The broker's issuer, such as `https://auth.example.com`. The run asks at `<issuer>/register`,
26
- * with a GitHub token whose audience is the issuer, so no other broker can use that token.
27
- */
28
- readonly issuer: string;
29
- }
30
- interface CommonProps {
31
- /**
32
- * The app's name in its repository. Default: the stack's path in the repository, `apps/samebase`
33
- * for the stack `samebase/samebase/apps/samebase`, and `app` for a stack named after the
34
- * repository. A changed name registers a new client under the new name.
35
- */
36
- readonly app?: string;
37
- /** The broker to register at. A changed broker registers a new client there; the old one stays. */
38
- readonly broker: BrokerEndpoint;
39
- /**
40
- * The connectors the client signs in through, by their names on the broker, such as
41
- * `["google", "github"]`: at least one, each of `[a-z0-9-]{1,64}`. The broker refuses a name it
42
- * does not offer, or does not allow this repository, and the log then names the allowed ones. The
43
- * set is recorded on the client for good: a changed set registers a new client.
44
- */
45
- readonly connectors: readonly string[];
46
- /**
47
- * The return addresses of this deployment, one to eight, such as
48
- * `[`${site.siteUrl}/auth/broker/callback`]`: each an https URL whose origin serves
49
- * `/samebase-verification.json` with the numeric GitHub id of this repository,
50
- * `{ "repository": "123" }`. They can come from a resource that this run creates. A development
51
- * client can also have http on a loopback host, which needs no file. Every request of the client
52
- * names one of them. The set is recorded on the client for good: a changed set registers a new
53
- * client.
54
- */
55
- readonly redirectUris: string[];
56
- /** Recorded on the broker's client, such as the commit. The broker records "unknown" without it. */
57
- readonly softwareVersion?: string;
58
- /**
59
- * The run fails unless the broker confirms the client in this run: it fails when the broker
60
- * refuses or does not answer a registration or a renewal, and when it suspended the client.
61
- * Without it, such a run gives the off values or keeps the saved client, so the app deploys
62
- * anyway. Set it where sign-in is the product. A failed run saves nothing, so the next run asks
63
- * the broker again.
64
- */
65
- readonly required?: boolean;
66
- }
67
- /**
68
- * A production or preview client asks with the GitHub OIDC token of the run. A development client
69
- * asks with the app's initial access token, which `IdentityBroker.Client.read` gives from stage
70
- * `prod`. A client of any type with `key` asks with that key, a key of a broker on the stack layer,
71
- * such as `IdentityBroker.registrationKey` gives.
72
- */
73
- export type ClientProps = (CommonProps & {
74
- readonly deploymentType: "production" | "preview";
75
- readonly initialAccessToken?: never;
76
- readonly key?: never;
77
- }) | (CommonProps & {
78
- readonly deploymentType: "development";
79
- /** Empty before the first production registration: the client gets the off values. */
80
- readonly initialAccessToken: Redacted.Redacted<string>;
81
- readonly key?: never;
82
- }) | (CommonProps & {
83
- readonly deploymentType: "production" | "preview" | "development";
84
- /**
85
- * The Bearer of `POST /register`. Undefined, as before the stage that makes the key ever
86
- * ran: the client gets the off values, or the run fails when `required`. The broker decides
87
- * whether this key may register a production client.
88
- */
89
- readonly key: Redacted.Redacted<string> | undefined;
90
- readonly initialAccessToken?: never;
91
- });
92
- declare const Attributes: Schema.Struct<{
93
- /** `off`: no client, and the values below are the off values. */
94
- readonly status: Schema.Literals<readonly ["on", "off", "suspended"]>;
95
- /** The issuer of the broker, which the deployment names to sign in. */
96
- readonly issuer: Schema.String;
97
- readonly clientId: Schema.String;
98
- /** Returned only at registration. */
99
- readonly clientSecret: Schema.Redacted<Schema.String>;
100
- /** Returned only at registration. It reads and deletes this client on the broker, and nothing else. */
101
- readonly registrationAccessToken: Schema.Redacted<Schema.String>;
102
- readonly registrationClientUri: Schema.String;
103
- readonly deploymentType: Schema.Literals<readonly ["production", "preview", "development"]>;
104
- /** The app's name on the broker, as sent. Empty for the off values. */
105
- readonly app: Schema.String;
106
- /** The return addresses the client serves, sorted, each once. Empty for the off values. */
107
- readonly redirectUris: Schema.$Array<Schema.String>;
108
- /** The connectors the client is enrolled in, sorted, each once. Empty for the off values. */
109
- readonly connectors: Schema.$Array<Schema.String>;
110
- /**
111
- * Returned only at a production registration (RFC 7591 section 1.2). It registers development
112
- * clients of this app. Empty for a preview, for a development client, and for the off values.
113
- */
114
- readonly initialAccessToken: Schema.Redacted<Schema.String>;
115
- /** The numeric GitHub id of the repository, with the initial access token. Empty without it. */
116
- readonly repository: Schema.String;
117
- }>;
118
- /**
119
- * The attributes keep the real values of a suspended client, so that an unblock needs no new client.
120
- * `IdentityBroker.Client.variables` gives the values that the app gets.
121
- */
122
- export interface ClientAttributes extends Schema.Schema.Type<typeof Attributes> {}
123
- /**
124
- * A key of a broker on the stack layer, as a redacted Output, for the broker's secret binding and
125
- * for `IdentityBroker.Client`'s `key`. `id` is the key's resource id, the author's name for it, so a
126
- * stack can make several. In `options.stage`, the stage that deploys the broker, the key is an
127
- * `Alchemy.Random` at the stack's root, made once and kept in state; the stack's providers need
128
- * Random's provider (`Convex.providers()` and `Cloudflare.providers()` hold one). Every other stage
129
- * reads that row from the state store, as `IdentityBroker.Client.read` does, so it never creates the
130
- * key; before the broker's stage ran, there is no row and no key (`undefined`).
131
- */
132
- export declare const registrationKey: (id: string, options: {
133
- readonly stage: string;
134
- }) => Effect.Effect<Output.Output<Redacted.Redacted<string> | undefined, any>, never, Stack | Provider.Provider<Random>>;
135
- export type Client = Resource<"IdentityBroker.Client", ClientProps, ClientAttributes, never, Providers>;
136
- export declare const Client: import("alchemy").ResourceClassWithMethods<Client, {
137
- readonly read: (id: string, options: {
138
- readonly stage: string;
139
- }) => Output.ObjectExpr<{
140
- readonly status: "on" | "off" | "suspended";
141
- readonly issuer: string;
142
- readonly clientId: string;
143
- readonly clientSecret: Redacted.Redacted<string>;
144
- readonly registrationAccessToken: Redacted.Redacted<string>;
145
- readonly registrationClientUri: string;
146
- readonly deploymentType: "production" | "preview" | "development";
147
- readonly app: string;
148
- readonly redirectUris: readonly string[];
149
- readonly connectors: readonly string[];
150
- readonly initialAccessToken: Redacted.Redacted<string>;
151
- readonly repository: string;
152
- }, State | Stack>;
153
- readonly variables: (client: Client) => Output.ObjectExpr<{
154
- issuer: string;
155
- clientId: string;
156
- clientSecret: Redacted.Redacted<string>;
157
- }, never>;
158
- }>;
159
- export declare const ClientProvider: () => import("effect/Layer").Layer<Provider.Provider<Client>, never, Stack>;
160
- //#endregion
161
- export {};
162
- //# sourceMappingURL=IdentityBroker.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IdentityBroker.d.ts","names":[],"sources":["../src/IdentityBroker.ts"],"mappings":";;;;;;;;;;;;qBAgEa;;;;;qBAiBA,aAAc;;;;;iBAYV;;;;;WAKN;;UAGD;;;;;;WAMC;;WAEA,QAAQ;;;;;;;WAOR;;;;;;;;;;WAUA;;WAEA;;;;;;;;WAQA;;;;;;;;YASC,eACP;WACU;WACA;WACA;MAEV;WACU;;WAEA,oBAAoB,SAAS;WAC7B;MAEV;WACU;;;;;;WAMA,KAAK,SAAS;WACd;;cAKT,YAAU,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA+BC,yBAAyB,OAAO,OAAO,YAAY;;;;;;;;;;qBAoevD,kBAAmB,YAAY;WAAoB;MAAe,OAAA,OAAA,OAAA,OAAA,SAAA,2CAAA,QAAA,SAAA,SAAA;YAkDnE,SAAS,kCAEnB,aACA,yBAEA;qBAEW,0BAAM,yBAAA;WAjGD,OAAA,YAAM;aAAsB;QAAe,OAAA;;;;;;;;;;;;;;WA2ElC,YAAA,QAAA,WAAM,OAAA;;;;;;qBA6BpB,6CAAc,MAAA,SAAA,SAAA,gBAAA"}
@@ -1 +0,0 @@
1
- export { t as Client, n as ClientProvider, r as DISABLED, i as defaultApp, a as registrationKey } from "./IdentityBroker-BqA_2V3_.js";
@@ -1,58 +0,0 @@
1
- import * as Effect from "effect/Effect";
2
- import * as Schema from "effect/Schema";
3
- import * as Context from "effect/Context";
4
- import * as Layer from "effect/Layer";
5
- import * as Redacted from "effect/Redacted";
6
- import * as Provider from "alchemy/Provider";
7
- //#region src/Credentials.d.ts
8
- interface ResolvedCredentials {
9
- /** Bearer token accepted by https://api.convex.dev/v1: a team access token, an OAuth token, or the Convex CLI login. */
10
- readonly accessToken: Redacted.Redacted<string>;
11
- /** Where the token came from, for error messages only. */
12
- readonly source: "env" | "explicit" | "convex-cli-login";
13
- }
14
- interface CredentialsService {
15
- /** The Management API token. Dies when there is none. */
16
- readonly accessToken: Effect.Effect<ResolvedCredentials>;
17
- /** True when there is a Management API token. */
18
- readonly hasAccessToken: Effect.Effect<boolean>;
19
- /** A deploy key or a preview deploy key, or undefined. */
20
- readonly deployKey: Effect.Effect<Redacted.Redacted<string> | undefined>;
21
- }
22
- declare const Credentials_base: Context.ServiceClass<Credentials, "@samebase/alchemy-convex/Credentials", CredentialsService>;
23
- declare class Credentials extends Credentials_base {}
24
- /** Environment variable for the access token, read by {@link fromConfig}. */
25
- declare const ACCESS_TOKEN_ENV = "CONVEX_ACCESS_TOKEN";
26
- /** Environment variable for the deploy key, read by {@link fromConfig}. The Convex CLI reads the same name. */
27
- declare const DEPLOY_KEY_ENV = "CONVEX_DEPLOY_KEY";
28
- declare const CredentialsError_base: Schema.Class<CredentialsError, Schema.TaggedStruct<"CredentialsError", {
29
- readonly reason: Schema.String;
30
- }>, import("effect/Cause").YieldableError>;
31
- declare class CredentialsError extends CredentialsError_base {}
32
- /**
33
- * Default resolution through the stack ConfigProvider (process env, `.env`,
34
- * stack secrets): `CONVEX_ACCESS_TOKEN`, then the Convex CLI login on this
35
- * machine, for the access token; `CONVEX_DEPLOY_KEY` for the deploy key. A
36
- * developer who ran `npx convex login` needs nothing. CI sets only the
37
- * deploy key when the stack pushes to deployments that exist, and the access
38
- * token when the stack also creates projects or deployments.
39
- */
40
- declare const fromConfig: () => Layer.Layer<Credentials>;
41
- /** Explicit values, for tests or callers that already hold them. */
42
- declare const fromValues: (values: {
43
- readonly accessToken?: Redacted.Redacted<string>;
44
- readonly deployKey?: Redacted.Redacted<string>;
45
- }) => Layer.Layer<Credentials>;
46
- //#endregion
47
- //#region src/Providers.d.ts
48
- declare const Providers_base: Provider.ProviderCollection<Providers, "Convex">;
49
- declare class Providers extends Providers_base {}
50
- /**
51
- * The Convex resource providers. Pass a credentials layer to override the
52
- * default lookup (`CONVEX_ACCESS_TOKEN`, then the Convex CLI login, and
53
- * `CONVEX_DEPLOY_KEY`).
54
- */
55
- declare const providers: (credentials?: Layer.Layer<Credentials>) => Layer.Layer<Providers, never, import("alchemy").Stack | import("effect/process/ChildProcessSpawner").ChildProcessSpawner | import("effect/FileSystem").FileSystem | import("effect/Path").Path>;
56
- //#endregion
57
- export { CredentialsError as a, fromValues as c, Credentials as i, providers as n, DEPLOY_KEY_ENV as o, ACCESS_TOKEN_ENV as r, fromConfig as s, Providers as t };
58
- //# sourceMappingURL=Providers-zL1fUs0r.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Providers-zL1fUs0r.d.ts","names":[],"sources":["../src/Credentials.ts","../src/Providers.ts"],"mappings":";;;;;;;UA6BiB;;WAEN,aAAa,SAAS;;WAEtB;;UAGM;;WAEN,aAAa,OAAO,OAAO;;WAE3B,gBAAgB,OAAO;;WAEvB,WAAW,OAAO,OAAO,SAAS;;;cAGhC,oBAAoB;;cAKpB;;cAGA;;;;cAOA,yBAAyB;;;;;;;;;cAiCzB,kBAAiB,MAAM,MAAM;;cA0B7B,aAAc;WAChB,cAAc,SAAS;WACvB,YAAY,SAAS;MAC5B,MAAM,MAAM;;;;cC9GH,kBAAkB;;;;;;cAOlB,YAAa,cAAa,MAAM,MAAM,iBAA2B,MAAA,MAAA,oCAAA,qDAAA,kDAAA,mCAAA"}