@gaganref/confect-core 10.3.1-fork.30 → 10.3.1-fork.32
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/dist/Auth.d.ts +22 -6
- package/dist/Auth.d.ts.map +1 -1
- package/dist/Auth.js +15 -1
- package/dist/Auth.js.map +1 -1
- package/package.json +1 -1
- package/src/Auth.ts +39 -6
package/dist/Auth.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { AuthProvider } from "convex/server";
|
|
2
2
|
import type * as App from "./App.js";
|
|
3
|
+
import type * as Env from "./Env.js";
|
|
3
4
|
import type { TypeError } from "./Types.js";
|
|
4
5
|
declare const TypeId = "~@confect/core/Auth";
|
|
6
|
+
declare const CloudUrlTypeId = "~@confect/core/Auth/CloudUrl";
|
|
5
7
|
declare const SiteUrlTypeId = "~@confect/core/Auth/SiteUrl";
|
|
6
8
|
/**
|
|
7
9
|
* The deployment's site URL (`CONVEX_SITE_URL`) plus a path, resolved when
|
|
@@ -11,15 +13,29 @@ export interface SiteUrl {
|
|
|
11
13
|
readonly [SiteUrlTypeId]: typeof SiteUrlTypeId;
|
|
12
14
|
readonly path: string;
|
|
13
15
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
|
+
* The deployment's cloud URL (`CONVEX_CLOUD_URL`) plus a path.
|
|
18
|
+
*/
|
|
19
|
+
export interface CloudUrl {
|
|
20
|
+
readonly [CloudUrlTypeId]: typeof CloudUrlTypeId;
|
|
21
|
+
readonly path: string;
|
|
22
|
+
}
|
|
23
|
+
type Url = string | SiteUrl | CloudUrl | Env.Entry<string, string, string, false>;
|
|
24
|
+
type WithUrls<P> = P extends unknown ? {
|
|
25
|
+
[K in keyof P]: K extends "domain" | "issuer" | "jwks" | "applicationID" ? Url : P[K];
|
|
17
26
|
} : never;
|
|
18
27
|
/**
|
|
19
|
-
* Convex's
|
|
20
|
-
|
|
28
|
+
* Convex's provider list with deployment URLs and required, public env strings.
|
|
29
|
+
*/
|
|
30
|
+
export type Provider = WithUrls<AuthProvider>;
|
|
31
|
+
/**
|
|
32
|
+
* The cloud URL, or a path under it, resolved when Convex loads auth config.
|
|
33
|
+
*/
|
|
34
|
+
export declare const cloudUrl: (path?: `/${string}` | "") => CloudUrl;
|
|
35
|
+
/**
|
|
36
|
+
* The path of a cloud URL placeholder, or `undefined` for another value.
|
|
21
37
|
*/
|
|
22
|
-
export
|
|
38
|
+
export declare const cloudUrlPath: (u: unknown) => string | undefined;
|
|
23
39
|
export interface Auth<A extends App.Any> {
|
|
24
40
|
readonly [TypeId]: typeof TypeId;
|
|
25
41
|
readonly app: A;
|
package/dist/Auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Auth.d.ts","sourceRoot":"","sources":["../src/Auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,KAAK,KAAK,GAAG,MAAM,UAAU,CAAC;AACrC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,QAAA,MAAM,MAAM,wBAAwB,CAAC;AACrC,QAAA,MAAM,aAAa,gCAAgC,CAAC;AAEpD;;;GAGG;AACH,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,CAAC,aAAa,CAAC,EAAE,OAAO,aAAa,CAAC;IAC/C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,KAAK,GAAG,
|
|
1
|
+
{"version":3,"file":"Auth.d.ts","sourceRoot":"","sources":["../src/Auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,KAAK,KAAK,GAAG,MAAM,UAAU,CAAC;AACrC,OAAO,KAAK,KAAK,GAAG,MAAM,UAAU,CAAC;AACrC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,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AC,QAAQ,CAAC,CAAC;CAC7C;AAED,MAAM,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAEhC;;;GAGG;AACH,wBAAgB,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,MAAM,EAAE,GAAG,OAAO,CAAC;AACtD,wBAAgB,OAAO,CACrB,KAAK,EAAE;IAAE,QAAQ,CAAC,UAAU,EAAE,GAAG,CAAC,UAAU,CAAA;CAAE,EAC9C,IAAI,CAAC,EAAE,IAAI,MAAM,EAAE,GAClB,OAAO,CAAC;AAcX,MAAM,MAAM,YAAY,GAAG,SAAS,CAClC,iGAAiG,EACjG,KAAK,CACN,CAAC;AAEF,KAAK,OAAO,CAAC,CAAC,SAAS,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GACzD,OAAO,GACP,YAAY,CAAC;AAEjB;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,IAAI,GAAI,CAAC,SAAS,GAAG,CAAC,GAAG,OAC/B,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,WACnB;IAAE,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAA;CAAE,KACvD,IAAI,CAAC,CAAC,CAA8D,CAAC;AAExE,eAAO,MAAM,MAAM,MAAO,OAAO,KAAG,CAAC,IAAI,GACiB,CAAC;AAE3D,eAAO,MAAM,SAAS,SAAU,GAAG,KAAG,aAAa,CAAC,QAAQ,CAAmB,CAAC;AAEhF;;GAEG;AACH,eAAO,MAAM,WAAW,MAAO,OAAO,KAAG,MAAM,GAAG,SAKnC,CAAC"}
|
package/dist/Auth.js
CHANGED
|
@@ -2,6 +2,8 @@ import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
|
2
2
|
import * as Predicate from "effect/Predicate";
|
|
3
3
|
//#region src/Auth.ts
|
|
4
4
|
var Auth_exports = /* @__PURE__ */ __exportAll({
|
|
5
|
+
cloudUrl: () => cloudUrl,
|
|
6
|
+
cloudUrlPath: () => cloudUrlPath,
|
|
5
7
|
isAuth: () => isAuth,
|
|
6
8
|
make: () => make,
|
|
7
9
|
providers: () => providers,
|
|
@@ -9,7 +11,19 @@ var Auth_exports = /* @__PURE__ */ __exportAll({
|
|
|
9
11
|
siteUrlPath: () => siteUrlPath
|
|
10
12
|
});
|
|
11
13
|
const TypeId = "~@confect/core/Auth";
|
|
14
|
+
const CloudUrlTypeId = "~@confect/core/Auth/CloudUrl";
|
|
12
15
|
const SiteUrlTypeId = "~@confect/core/Auth/SiteUrl";
|
|
16
|
+
/**
|
|
17
|
+
* The cloud URL, or a path under it, resolved when Convex loads auth config.
|
|
18
|
+
*/
|
|
19
|
+
const cloudUrl = (path = "") => ({
|
|
20
|
+
[CloudUrlTypeId]: CloudUrlTypeId,
|
|
21
|
+
path
|
|
22
|
+
});
|
|
23
|
+
/**
|
|
24
|
+
* The path of a cloud URL placeholder, or `undefined` for another value.
|
|
25
|
+
*/
|
|
26
|
+
const cloudUrlPath = (u) => Predicate.hasProperty(u, CloudUrlTypeId) && Predicate.hasProperty(u, "path") && typeof u.path === "string" ? u.path : void 0;
|
|
13
27
|
function siteUrl(pathOrMount, path = "") {
|
|
14
28
|
return {
|
|
15
29
|
[SiteUrlTypeId]: SiteUrlTypeId,
|
|
@@ -41,6 +55,6 @@ const providers = (auth) => auth.providers;
|
|
|
41
55
|
*/
|
|
42
56
|
const siteUrlPath = (u) => Predicate.hasProperty(u, SiteUrlTypeId) && Predicate.hasProperty(u, "path") && typeof u.path === "string" ? u.path : void 0;
|
|
43
57
|
//#endregion
|
|
44
|
-
export { Auth_exports, isAuth, make, providers, siteUrl, siteUrlPath };
|
|
58
|
+
export { Auth_exports, cloudUrl, cloudUrlPath, isAuth, make, providers, siteUrl, siteUrlPath };
|
|
45
59
|
|
|
46
60
|
//# sourceMappingURL=Auth.js.map
|
package/dist/Auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Auth.js","names":[],"sources":["../src/Auth.ts"],"sourcesContent":["import type { AuthProvider } from \"convex/server\";\nimport * as Predicate from \"effect/Predicate\";\nimport type * as App from \"./App.js\";\nimport type { TypeError } from \"./Types.js\";\n\nconst TypeId = \"~@confect/core/Auth\";\nconst SiteUrlTypeId = \"~@confect/core/Auth/SiteUrl\";\n\n/**\n * The deployment's site URL (`CONVEX_SITE_URL`) plus a path, resolved when\n * Convex loads `auth.config.ts`.\n */\nexport interface SiteUrl {\n readonly [SiteUrlTypeId]: typeof SiteUrlTypeId;\n readonly path: string;\n}\n\ntype Url
|
|
1
|
+
{"version":3,"file":"Auth.js","names":[],"sources":["../src/Auth.ts"],"sourcesContent":["import type { AuthProvider } from \"convex/server\";\nimport * as Predicate from \"effect/Predicate\";\nimport type * as App from \"./App.js\";\nimport type * as Env from \"./Env.js\";\nimport type { TypeError } from \"./Types.js\";\n\nconst TypeId = \"~@confect/core/Auth\";\nconst CloudUrlTypeId = \"~@confect/core/Auth/CloudUrl\";\nconst SiteUrlTypeId = \"~@confect/core/Auth/SiteUrl\";\n\n/**\n * The deployment's site URL (`CONVEX_SITE_URL`) plus a path, resolved when\n * Convex loads `auth.config.ts`.\n */\nexport interface SiteUrl {\n readonly [SiteUrlTypeId]: typeof SiteUrlTypeId;\n readonly path: string;\n}\n\n/**\n * The deployment's cloud URL (`CONVEX_CLOUD_URL`) plus a path.\n */\nexport interface CloudUrl {\n readonly [CloudUrlTypeId]: typeof CloudUrlTypeId;\n readonly path: string;\n}\n\ntype Url =\n | string\n | SiteUrl\n | CloudUrl\n | Env.Entry<string, string, string, false>;\n\ntype WithUrls<P> = P extends unknown\n ? {\n [K in keyof P]: K extends \"domain\" | \"issuer\" | \"jwks\" | \"applicationID\"\n ? Url\n : P[K];\n }\n : never;\n\n/**\n * Convex's provider list with deployment URLs and required, public env strings.\n */\nexport type Provider = WithUrls<AuthProvider>;\n\n/**\n * The cloud URL, or a path under it, resolved when Convex loads auth config.\n */\nexport const cloudUrl = (path: `/${string}` | \"\" = \"\"): CloudUrl => ({\n [CloudUrlTypeId]: CloudUrlTypeId,\n path,\n});\n\n/**\n * The path of a cloud URL placeholder, or `undefined` for another value.\n */\nexport const cloudUrlPath = (u: unknown): string | undefined =>\n Predicate.hasProperty(u, CloudUrlTypeId) &&\n Predicate.hasProperty(u, \"path\") &&\n typeof u.path === \"string\"\n ? u.path\n : undefined;\n\nexport interface Auth<A extends App.Any> {\n readonly [TypeId]: typeof TypeId;\n readonly app: A;\n readonly providers: ReadonlyArray<Provider>;\n}\n\nexport type Any = Auth<App.Any>;\n\n/**\n * The site URL, or a path under it. Pass a mount to point at that mounted\n * component's HTTP routes.\n */\nexport function siteUrl(path?: `/${string}`): SiteUrl;\nexport function siteUrl(\n mount: { readonly httpPrefix: App.HttpPrefix },\n path?: `/${string}`,\n): SiteUrl;\nexport function siteUrl(\n pathOrMount?: `/${string}` | { readonly httpPrefix: App.HttpPrefix },\n path: string = \"\",\n): SiteUrl {\n return {\n [SiteUrlTypeId]: SiteUrlTypeId,\n path:\n typeof pathOrMount === \"object\"\n ? pathOrMount.httpPrefix.replace(/\\/+$/, \"\") + path\n : (pathOrMount ?? \"\"),\n };\n}\n\nexport type AppOnlyError = TypeError<\n \"Auth.make accepts only app declarations; components receive identity through function arguments\",\n never\n>;\n\ntype AppOnly<A extends App.Any> = [A[\"kind\"]] extends [\"app\"]\n ? unknown\n : AppOnlyError;\n\n/**\n * Declare the identity providers whose tokens the backend accepts, in\n * `confect/auth.ts`. This is Convex's own provider list; codegen writes it to\n * `convex/auth.config.ts`.\n *\n * ```ts\n * export default Auth.make(app, {\n * providers: [\n * { domain: \"https://login.example.edu\", applicationID: \"tenant\" },\n * ],\n * });\n * ```\n */\nexport const make = <A extends App.Any>(\n app: A & AppOnly<NoInfer<A>>,\n options: { readonly providers: ReadonlyArray<Provider> },\n): Auth<A> => ({ [TypeId]: TypeId, app, providers: options.providers });\n\nexport const isAuth = (u: unknown): u is Any =>\n Predicate.hasProperty(u, TypeId) && u[TypeId] === TypeId;\n\nexport const providers = (auth: Any): ReadonlyArray<Provider> => auth.providers;\n\n/**\n * The path of a {@link SiteUrl}, or `undefined` for any other value.\n */\nexport const siteUrlPath = (u: unknown): string | undefined =>\n Predicate.hasProperty(u, SiteUrlTypeId) &&\n Predicate.hasProperty(u, \"path\") &&\n typeof u.path === \"string\"\n ? u.path\n : undefined;\n"],"mappings":";;;;;;;;;;;;AAMA,MAAM,SAAS;AACf,MAAM,iBAAiB;AACvB,MAAM,gBAAgB;;;;AAyCtB,MAAa,YAAY,OAA0B,QAAkB;EAClE,iBAAiB;CAClB;AACF;;;;AAKA,MAAa,gBAAgB,MAC3B,UAAU,YAAY,GAAG,cAAc,KACvC,UAAU,YAAY,GAAG,MAAM,KAC/B,OAAO,EAAE,SAAS,WACd,EAAE,OACF,KAAA;AAmBN,SAAgB,QACd,aACA,OAAe,IACN;CACT,OAAO;GACJ,gBAAgB;EACjB,MACE,OAAO,gBAAgB,WACnB,YAAY,WAAW,QAAQ,QAAQ,EAAE,IAAI,OAC5C,eAAe;CACxB;AACF;;;;;;;;;;;;;;AAwBA,MAAa,QACX,KACA,aACa;EAAG,SAAS;CAAQ;CAAK,WAAW,QAAQ;AAAU;AAErE,MAAa,UAAU,MACrB,UAAU,YAAY,GAAG,MAAM,KAAK,EAAE,YAAY;AAEpD,MAAa,aAAa,SAAuC,KAAK;;;;AAKtE,MAAa,eAAe,MAC1B,UAAU,YAAY,GAAG,aAAa,KACtC,UAAU,YAAY,GAAG,MAAM,KAC/B,OAAO,EAAE,SAAS,WACd,EAAE,OACF,KAAA"}
|
package/package.json
CHANGED
package/src/Auth.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { AuthProvider } from "convex/server";
|
|
2
2
|
import * as Predicate from "effect/Predicate";
|
|
3
3
|
import type * as App from "./App.js";
|
|
4
|
+
import type * as Env from "./Env.js";
|
|
4
5
|
import type { TypeError } from "./Types.js";
|
|
5
6
|
|
|
6
7
|
const TypeId = "~@confect/core/Auth";
|
|
8
|
+
const CloudUrlTypeId = "~@confect/core/Auth/CloudUrl";
|
|
7
9
|
const SiteUrlTypeId = "~@confect/core/Auth/SiteUrl";
|
|
8
10
|
|
|
9
11
|
/**
|
|
@@ -15,19 +17,50 @@ export interface SiteUrl {
|
|
|
15
17
|
readonly path: string;
|
|
16
18
|
}
|
|
17
19
|
|
|
18
|
-
|
|
20
|
+
/**
|
|
21
|
+
* The deployment's cloud URL (`CONVEX_CLOUD_URL`) plus a path.
|
|
22
|
+
*/
|
|
23
|
+
export interface CloudUrl {
|
|
24
|
+
readonly [CloudUrlTypeId]: typeof CloudUrlTypeId;
|
|
25
|
+
readonly path: string;
|
|
26
|
+
}
|
|
19
27
|
|
|
20
|
-
type
|
|
28
|
+
type Url =
|
|
29
|
+
| string
|
|
30
|
+
| SiteUrl
|
|
31
|
+
| CloudUrl
|
|
32
|
+
| Env.Entry<string, string, string, false>;
|
|
33
|
+
|
|
34
|
+
type WithUrls<P> = P extends unknown
|
|
21
35
|
? {
|
|
22
|
-
[K in keyof P]: K extends "domain" | "issuer" | "jwks"
|
|
36
|
+
[K in keyof P]: K extends "domain" | "issuer" | "jwks" | "applicationID"
|
|
37
|
+
? Url
|
|
38
|
+
: P[K];
|
|
23
39
|
}
|
|
24
40
|
: never;
|
|
25
41
|
|
|
26
42
|
/**
|
|
27
|
-
* Convex's
|
|
28
|
-
|
|
43
|
+
* Convex's provider list with deployment URLs and required, public env strings.
|
|
44
|
+
*/
|
|
45
|
+
export type Provider = WithUrls<AuthProvider>;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The cloud URL, or a path under it, resolved when Convex loads auth config.
|
|
29
49
|
*/
|
|
30
|
-
export
|
|
50
|
+
export const cloudUrl = (path: `/${string}` | "" = ""): CloudUrl => ({
|
|
51
|
+
[CloudUrlTypeId]: CloudUrlTypeId,
|
|
52
|
+
path,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The path of a cloud URL placeholder, or `undefined` for another value.
|
|
57
|
+
*/
|
|
58
|
+
export const cloudUrlPath = (u: unknown): string | undefined =>
|
|
59
|
+
Predicate.hasProperty(u, CloudUrlTypeId) &&
|
|
60
|
+
Predicate.hasProperty(u, "path") &&
|
|
61
|
+
typeof u.path === "string"
|
|
62
|
+
? u.path
|
|
63
|
+
: undefined;
|
|
31
64
|
|
|
32
65
|
export interface Auth<A extends App.Any> {
|
|
33
66
|
readonly [TypeId]: typeof TypeId;
|