@samebase/alchemy-convex 0.45.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.
- package/README.md +9 -144
- package/lib/{State-Bp7iSx8T.js → State-Dd88J2_z.js} +2 -2
- package/lib/{State-Bp7iSx8T.js.map → State-Dd88J2_z.js.map} +1 -1
- package/lib/cli.js +2 -2
- package/lib/index.d.ts +52 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -7
- package/lib/index.js.map +1 -1
- package/package.json +1 -5
- package/src/Providers.ts +2 -15
- package/lib/IdentityHub-CDG7GXm6.js +0 -423
- package/lib/IdentityHub-CDG7GXm6.js.map +0 -1
- package/lib/IdentityHub.d.ts +0 -159
- package/lib/IdentityHub.d.ts.map +0 -1
- package/lib/IdentityHub.js +0 -1
- package/lib/Providers-zL1fUs0r.d.ts +0 -58
- package/lib/Providers-zL1fUs0r.d.ts.map +0 -1
- package/src/IdentityHub.ts +0 -830
package/lib/IdentityHub.d.ts
DELETED
|
@@ -1,159 +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/IdentityHub.d.ts
|
|
12
|
-
/**
|
|
13
|
-
* The app's default name: the stack's path below `owner/repo`, or `app` for a stack named after
|
|
14
|
-
* the repository. Undefined for a stack whose name is not `owner/repo` or `owner/repo/<path>`.
|
|
15
|
-
*/
|
|
16
|
-
export declare const defaultApp: (stackName: string) => string | undefined;
|
|
17
|
-
/**
|
|
18
|
-
* An identity hub of @samebase/identity-broker, such as Samebase's public hub:
|
|
19
|
-
* `{ issuer: "https://id.samebase.com" }`.
|
|
20
|
-
*/
|
|
21
|
-
export interface Hub {
|
|
22
|
-
/**
|
|
23
|
-
* The hub's issuer, such as `https://auth.example.com`. The run asks at `<issuer>/register`, with
|
|
24
|
-
* a GitHub token whose audience is the issuer, so no other hub can use that token.
|
|
25
|
-
*/
|
|
26
|
-
readonly issuer: string;
|
|
27
|
-
}
|
|
28
|
-
interface CommonProps {
|
|
29
|
-
/**
|
|
30
|
-
* The app's name in its repository. Default: the stack's path in the repository, `apps/samebase`
|
|
31
|
-
* for the stack `samebase/samebase/apps/samebase`, and `app` for a stack named after the
|
|
32
|
-
* repository. A changed name registers a new client under the new name.
|
|
33
|
-
*/
|
|
34
|
-
readonly app?: string;
|
|
35
|
-
/** The hub to register at. A changed hub registers a new client there; the old one stays. */
|
|
36
|
-
readonly hub: Hub;
|
|
37
|
-
/**
|
|
38
|
-
* The connectors the client signs in through, by their names on the hub, such as
|
|
39
|
-
* `["google", "github"]`: at least one, each of `[a-z0-9-]{1,64}`. The hub refuses a name it does
|
|
40
|
-
* not offer, or does not allow this repository, and the log then names the allowed ones. The set
|
|
41
|
-
* is recorded on the client for good: a changed set registers a new client.
|
|
42
|
-
*/
|
|
43
|
-
readonly connectors: readonly string[];
|
|
44
|
-
/**
|
|
45
|
-
* The return addresses of this deployment, one to eight, such as
|
|
46
|
-
* `[`${site.siteUrl}/auth/hub/callback`]`: each an https URL whose origin serves
|
|
47
|
-
* `/samebase-verification.json` with the numeric GitHub id of this repository,
|
|
48
|
-
* `{ "repository": "123" }`. They can come from a resource that this run creates. A development
|
|
49
|
-
* client can also have http on a loopback host, which needs no file. Every request of the client
|
|
50
|
-
* names one of them. The set is recorded on the client for good: a changed set registers a new
|
|
51
|
-
* client.
|
|
52
|
-
*/
|
|
53
|
-
readonly redirectUris: string[];
|
|
54
|
-
/** Recorded on the hub's client, such as the commit. The hub records "unknown" without it. */
|
|
55
|
-
readonly softwareVersion?: string;
|
|
56
|
-
/**
|
|
57
|
-
* The run fails unless the hub confirms the client in this run: it fails when the hub refuses or
|
|
58
|
-
* does not answer a registration or a renewal, and when it suspended the client. Without it, such
|
|
59
|
-
* a run gives the off values or keeps the saved client, so the app deploys anyway. Set it where
|
|
60
|
-
* sign-in is the product. A failed run saves nothing, so the next run asks the hub again.
|
|
61
|
-
*/
|
|
62
|
-
readonly required?: boolean;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* A production or preview client asks with the GitHub OIDC token of the run. A development client
|
|
66
|
-
* asks with the app's initial access token, which `IdentityHub.Client.read` gives from stage `prod`.
|
|
67
|
-
* A client of any type with `key` asks with that key, a key of a hub on the stack layer, such as
|
|
68
|
-
* `IdentityHub.registrationKey` gives.
|
|
69
|
-
*/
|
|
70
|
-
export type ClientProps = (CommonProps & {
|
|
71
|
-
readonly deploymentType: "production" | "preview";
|
|
72
|
-
readonly initialAccessToken?: never;
|
|
73
|
-
readonly key?: never;
|
|
74
|
-
}) | (CommonProps & {
|
|
75
|
-
readonly deploymentType: "development";
|
|
76
|
-
/** Empty before the first production registration: the client gets the off values. */
|
|
77
|
-
readonly initialAccessToken: Redacted.Redacted<string>;
|
|
78
|
-
readonly key?: never;
|
|
79
|
-
}) | (CommonProps & {
|
|
80
|
-
readonly deploymentType: "production" | "preview" | "development";
|
|
81
|
-
/**
|
|
82
|
-
* The Bearer of `POST /register`. Undefined, as before the stage that makes the key ever
|
|
83
|
-
* ran: the client gets the off values, or the run fails when `required`. The hub decides
|
|
84
|
-
* whether this key may register a production client.
|
|
85
|
-
*/
|
|
86
|
-
readonly key: Redacted.Redacted<string> | undefined;
|
|
87
|
-
readonly initialAccessToken?: never;
|
|
88
|
-
});
|
|
89
|
-
declare const Attributes: Schema.Struct<{
|
|
90
|
-
/** `off`: no client, and the values below are the off values. */
|
|
91
|
-
readonly status: Schema.Literals<readonly ["on", "off", "suspended"]>;
|
|
92
|
-
/** The issuer of the hub, which the deployment names to sign in. */
|
|
93
|
-
readonly issuer: Schema.String;
|
|
94
|
-
readonly clientId: Schema.String;
|
|
95
|
-
/** Returned only at registration. */
|
|
96
|
-
readonly clientSecret: Schema.Redacted<Schema.String>;
|
|
97
|
-
/** Returned only at registration. It reads and deletes this client on the hub, and nothing else. */
|
|
98
|
-
readonly registrationAccessToken: Schema.Redacted<Schema.String>;
|
|
99
|
-
readonly registrationClientUri: Schema.String;
|
|
100
|
-
readonly deploymentType: Schema.Literals<readonly ["production", "preview", "development"]>;
|
|
101
|
-
/** The app's name on the hub, as sent. Empty for the off values. */
|
|
102
|
-
readonly app: Schema.String;
|
|
103
|
-
/** The return addresses the client serves, sorted, each once. Empty for the off values. */
|
|
104
|
-
readonly redirectUris: Schema.$Array<Schema.String>;
|
|
105
|
-
/** The connectors the client is enrolled in, sorted, each once. Empty for the off values. */
|
|
106
|
-
readonly connectors: Schema.$Array<Schema.String>;
|
|
107
|
-
/**
|
|
108
|
-
* Returned only at a production registration (RFC 7591 section 1.2). It registers development
|
|
109
|
-
* clients of this app. Empty for a preview, for a development client, and for the off values.
|
|
110
|
-
*/
|
|
111
|
-
readonly initialAccessToken: Schema.Redacted<Schema.String>;
|
|
112
|
-
/** The numeric GitHub id of the repository, with the initial access token. Empty without it. */
|
|
113
|
-
readonly repository: Schema.String;
|
|
114
|
-
}>;
|
|
115
|
-
/**
|
|
116
|
-
* The attributes keep the real values of a suspended client, so that an unblock needs no new client.
|
|
117
|
-
* `IdentityHub.Client.variables` gives the values that the app gets.
|
|
118
|
-
*/
|
|
119
|
-
export interface ClientAttributes extends Schema.Schema.Type<typeof Attributes> {}
|
|
120
|
-
/**
|
|
121
|
-
* A key of a hub on the stack layer, as a redacted Output, for the hub's secret binding and for
|
|
122
|
-
* `IdentityHub.Client`'s `key`. `id` is the key's resource id, the author's name for it, so a stack
|
|
123
|
-
* can make several. In `options.stage`, the stage that deploys the hub, the key is an
|
|
124
|
-
* `Alchemy.Random` at the stack's root, made once and kept in state; the stack's providers need
|
|
125
|
-
* Random's provider (`Convex.providers()` and `Cloudflare.providers()` hold one). Every other stage
|
|
126
|
-
* reads that row from the state store, as `IdentityHub.Client.read` does, so it never creates the
|
|
127
|
-
* key; before the hub's stage ran, there is no row and no key (`undefined`).
|
|
128
|
-
*/
|
|
129
|
-
export declare const registrationKey: (id: string, options: {
|
|
130
|
-
readonly stage: string;
|
|
131
|
-
}) => Effect.Effect<Output.Output<Redacted.Redacted<string> | undefined, any>, never, Stack | Provider.Provider<Random>>;
|
|
132
|
-
export type Client = Resource<"IdentityHub.Client", ClientProps, ClientAttributes, never, Providers>;
|
|
133
|
-
export declare const Client: import("alchemy").ResourceClassWithMethods<Client, {
|
|
134
|
-
readonly read: (id: string, options: {
|
|
135
|
-
readonly stage: string;
|
|
136
|
-
}) => Output.ObjectExpr<{
|
|
137
|
-
readonly status: "on" | "off" | "suspended";
|
|
138
|
-
readonly issuer: string;
|
|
139
|
-
readonly clientId: string;
|
|
140
|
-
readonly clientSecret: Redacted.Redacted<string>;
|
|
141
|
-
readonly registrationAccessToken: Redacted.Redacted<string>;
|
|
142
|
-
readonly registrationClientUri: string;
|
|
143
|
-
readonly deploymentType: "production" | "preview" | "development";
|
|
144
|
-
readonly app: string;
|
|
145
|
-
readonly redirectUris: readonly string[];
|
|
146
|
-
readonly connectors: readonly string[];
|
|
147
|
-
readonly initialAccessToken: Redacted.Redacted<string>;
|
|
148
|
-
readonly repository: string;
|
|
149
|
-
}, State | Stack>;
|
|
150
|
-
readonly variables: (client: Client) => Output.ObjectExpr<{
|
|
151
|
-
issuer: string;
|
|
152
|
-
clientId: string;
|
|
153
|
-
clientSecret: Redacted.Redacted<string>;
|
|
154
|
-
}, never>;
|
|
155
|
-
}>;
|
|
156
|
-
export declare const ClientProvider: () => import("effect/Layer").Layer<Provider.Provider<Client>, never, Stack>;
|
|
157
|
-
//#endregion
|
|
158
|
-
export {};
|
|
159
|
-
//# sourceMappingURL=IdentityHub.d.ts.map
|
package/lib/IdentityHub.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IdentityHub.d.ts","names":[],"sources":["../src/IdentityHub.ts"],"mappings":";;;;;;;;;;;;;;;qBA8Ea,aAAc;;;;;iBAYV;;;;;WAKN;;UAGD;;;;;;WAMC;;WAEA,KAAK;;;;;;;WAOL;;;;;;;;;;WAUA;;WAEA;;;;;;;WAOA;;;;;;;;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;;;;;;;;;;qBAudvD,kBAAmB,YAAY;WAAoB;MAAe,OAAA,OAAA,OAAA,OAAA,SAAA,2CAAA,QAAA,SAAA,SAAA;YAkDnE,SAAS,+BAEnB,aACA,yBAEA;qBAEW,0BAAM,yBAAA;WAjGD,OAAA,YAAM;aAAsB;QAAe,OAAA;;;;;;;;;;;;;;WA2ElC,YAAA,QAAA,WAAM,OAAA;;;;;;qBA2BpB,6CAAc,MAAA,SAAA,SAAA,gBAAA"}
|
package/lib/IdentityHub.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { t as Client, n as ClientProvider, r as defaultApp, i as registrationKey } from "./IdentityHub-CDG7GXm6.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"}
|