@stackframe/stack-shared 2.8.31 → 2.8.34
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/CHANGELOG.md +18 -0
- package/dist/config/schema.d.mts +104 -104
- package/dist/config/schema.d.ts +104 -104
- package/dist/config/schema.js +1 -1
- package/dist/config/schema.js.map +1 -1
- package/dist/esm/config/schema.js +1 -1
- package/dist/esm/config/schema.js.map +1 -1
- package/dist/esm/helpers/production-mode.js +2 -1
- package/dist/esm/helpers/production-mode.js.map +1 -1
- package/dist/esm/interface/admin-interface.js +16 -19
- package/dist/esm/interface/admin-interface.js.map +1 -1
- package/dist/esm/interface/client-interface.js +36 -8
- package/dist/esm/interface/client-interface.js.map +1 -1
- package/dist/esm/interface/crud/items.js +22 -0
- package/dist/esm/interface/crud/items.js.map +1 -0
- package/dist/esm/interface/crud/users.js +1 -1
- package/dist/esm/interface/crud/users.js.map +1 -1
- package/dist/esm/interface/server-interface.js +21 -0
- package/dist/esm/interface/server-interface.js.map +1 -1
- package/dist/esm/known-errors.js +14 -5
- package/dist/esm/known-errors.js.map +1 -1
- package/dist/esm/schema-fields.js +31 -1
- package/dist/esm/schema-fields.js.map +1 -1
- package/dist/esm/utils/jwt.js +42 -37
- package/dist/esm/utils/jwt.js.map +1 -1
- package/dist/esm/utils/types.js.map +1 -1
- package/dist/esm/utils/urls.js +54 -0
- package/dist/esm/utils/urls.js.map +1 -1
- package/dist/helpers/password.d.mts +3 -0
- package/dist/helpers/password.d.ts +3 -0
- package/dist/helpers/production-mode.js +2 -1
- package/dist/helpers/production-mode.js.map +1 -1
- package/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/interface/admin-interface.d.mts +5 -9
- package/dist/interface/admin-interface.d.ts +5 -9
- package/dist/interface/admin-interface.js +16 -19
- package/dist/interface/admin-interface.js.map +1 -1
- package/dist/interface/client-interface.d.mts +14 -8
- package/dist/interface/client-interface.d.ts +14 -8
- package/dist/interface/client-interface.js +36 -8
- package/dist/interface/client-interface.js.map +1 -1
- package/dist/interface/crud/items.d.mts +30 -0
- package/dist/interface/crud/items.d.ts +30 -0
- package/dist/interface/crud/items.js +47 -0
- package/dist/interface/crud/items.js.map +1 -0
- package/dist/interface/crud/project-api-keys.d.mts +4 -4
- package/dist/interface/crud/project-api-keys.d.ts +4 -4
- package/dist/interface/crud/projects.d.mts +7 -7
- package/dist/interface/crud/projects.d.ts +7 -7
- package/dist/interface/crud/users.js +1 -1
- package/dist/interface/crud/users.js.map +1 -1
- package/dist/interface/server-interface.d.mts +6 -0
- package/dist/interface/server-interface.d.ts +6 -0
- package/dist/interface/server-interface.js +21 -0
- package/dist/interface/server-interface.js.map +1 -1
- package/dist/known-errors.d.mts +4 -1
- package/dist/known-errors.d.ts +4 -1
- package/dist/known-errors.js +14 -5
- package/dist/known-errors.js.map +1 -1
- package/dist/schema-fields.d.mts +6 -2
- package/dist/schema-fields.d.ts +6 -2
- package/dist/schema-fields.js +31 -0
- package/dist/schema-fields.js.map +1 -1
- package/dist/utils/jwt.d.mts +11 -11
- package/dist/utils/jwt.d.ts +11 -11
- package/dist/utils/jwt.js +44 -42
- package/dist/utils/jwt.js.map +1 -1
- package/dist/utils/types.d.mts +11 -1
- package/dist/utils/types.d.ts +11 -1
- package/dist/utils/types.js.map +1 -1
- package/dist/utils/urls.d.mts +3 -1
- package/dist/utils/urls.d.ts +3 -1
- package/dist/utils/urls.js +56 -0
- package/dist/utils/urls.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/types.tsx"],"sourcesContent":["import { DeepPartial } from \"./objects\";\nimport { Join } from \"./strings\";\n\nexport type IsAny<T> = 0 extends (1 & T) ? true : false;\nexport type IsNever<T> = [T] extends [never] ? true : false;\nexport type IsNullish<T> = [T] extends [null | undefined] ? true : false;\nexport type IsUnion<T, U = T> =\n IsNever<T> extends true ? false\n : IsAny<T> extends true ? false\n : T extends U // distributive conditional https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types\n ? /* if the *whole* original type (`U`) still fits inside the current variant, then `T` wasn’t a union */ ([U] extends [T] ? false : true)\n : never;\n\nexport type NullishCoalesce<T, U> = T extends null | undefined ? U : T;\n\nexport type LastUnionElement<U> = UnionToIntersection<U extends any ? (x: U) => 0 : never> extends (x: infer L) => 0 ? L & U : never;\n\n/**\n * Makes a type prettier by recursively expanding all object types. For example, `Omit<{ a: 1 }, \"a\">` becomes just `{}`.\n */\nexport type Expand<T> = T extends (...args: infer A) => infer R\n ? (\n ((...args: A) => R) extends T\n ? (...args: Expand<A>) => Expand<R>\n : ((...args: Expand<A>) => Expand<R>) & { [K in keyof T]: Expand<T[K]> }\n )\n : (\n T extends object\n ? { [K in keyof T]: Expand<T[K]> }\n : T\n );\n\n\n/**\n * Removes all optional undefined/never keys from an object.\n */\nexport type DeepRemoveOptionalUndefined<T> = T extends object ? { [K in keyof T]: DeepRemoveOptionalUndefined<T[K]> } : T;\n\n// why this works: https://stackoverflow.com/a/50375286\nexport type UnionToIntersection<U> =\n (U extends any ? (x: U) => void : never) extends ((x: infer I) => void) ? I : never\n\ntype _UnionToTupleInner<U, R extends any[], Last> = UnionToTuple<Exclude<U, Last>, [...R, Last]>\nexport type UnionToTuple<U, R extends any[] = []> = [U] extends [never] ? R : _UnionToTupleInner<U, R, LastUnionElement<U>>;\n\nexport type CollapseObjectUnion<T extends object> = {\n [K in AllUnionKeys<T>]?: T extends Record<K, infer V> ? V : never;\n};\ntypeAssertIs<CollapseObjectUnion<{ a: string } | { b: number }>, { a?: string, b?: number }>()();\ntypeAssertIs<CollapseObjectUnion<{ a: string } | { a: number }>, { a?: string | number }>()();\n\nexport type IntersectAll<T extends any[]> = UnionToIntersection<T[number]>;\n\nexport type OptionalKeys<T> = {\n [K in keyof T]: {} extends Pick<T, K> ? K : never;\n}[keyof T];\nexport type RequiredKeys<T> = {\n [K in keyof T]: {} extends Pick<T, K> ? never : K;\n}[keyof T];\n\n/**\n * Returns ALL keys of all union elements.\n */\nexport type AllUnionKeys<T extends object> = T extends T ? keyof T : never;\ntypeAssertIs<AllUnionKeys<{ a: string } | { b: number }>, \"a\" | \"b\">()();\n\nexport type SubtractType<T, U> = T extends object ? { [K in keyof T]: K extends keyof U ? SubtractType<T[K], U[K]> : T[K] } : (T extends U ? never : T); // note: this only works due to the distributive property of conditional types https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types\n\n\ntype _AntiIntersectInner<T, U> = T extends object ? (\n & Omit<U, keyof T>\n & { [K in keyof Pick<U, { [K in keyof T & keyof U]: U[K] extends T[K] ? (T[K] extends U[K] ? never : K) : never }[keyof T & keyof U]>]: PseudoAntiIntersect<T[K], U[K]> }\n & { [K in keyof Pick<U, keyof T & keyof U>]?: PseudoAntiIntersect<T[K], U[K]> }\n) : U;\n/**\n * Returns a type R such that T & R = U.\n */\nexport type AntiIntersect<T, U> = U extends T ? _AntiIntersectInner<T, U> : \"Cannot anti-intersect a type with a type that is not a subtype of it\"; // NOTE: This type is mostly untested — not sure how well it works on the edge cases\nexport type PseudoAntiIntersect<T, U> = _AntiIntersectInner<T, T & U>;\n\n/**\n * A variation of TypeScript's conditionals with slightly different semantics. It is the perfect type for cases where:\n *\n * - If all possible values are contained in `Extends`, then it will be mapped to `Then`.\n * - If all possible values are not contained in `Extends`, then it will be mapped to `Otherwise`.\n * - If some possible values are contained in `Extends` and some are not, then it will be mapped to `Then | Otherwise`.\n *\n * This is different from TypeScript's built-in conditional types (`Value extends Extends ? Then : Otherwise`), which\n * returns `Otherwise` for the third case (causing unsoundness in many real-world cases).\n */\nexport type IfAndOnlyIf<Value, Extends, Then, Otherwise> =\n | (Value extends Extends ? never : Otherwise)\n | (Value & Extends extends never ? never : Then);\n\n\n/**\n * Can be used to prettify a type in the IDE; for example, some complicated intersected types can be flattened into a single type.\n */\nexport type PrettifyType<T> = T extends object ? { [K in keyof T]: T[K] } & {} : T;\n\ntype _ToStringAndJoin<T extends any[], Separator extends string> =\n T extends [infer U, ...infer Rest extends any[]]\n ? `${TypeToString<U>}${Rest extends [any, ...any[]] ? `${Separator}${_ToStringAndJoin<Rest, Separator>}` : \"\"}`\n : \"<error-joining-tuple-elements>\";\ntype _TypeToStringInner<T> =\n IsAny<T> extends true ? \"any\"\n : IsNever<T> extends true ? \"never\"\n : IsUnion<T> extends true ? _ToStringAndJoin<UnionToTuple<T>, \" | \">\n : [T] extends [number] ? (number extends T ? \"number\" : `${T}`)\n : [T] extends [boolean] ? `${T}`\n : [T] extends [undefined] ? \"undefined\"\n : [T] extends [null] ? \"null\"\n : [T] extends [string] ? (string extends T ? \"string\" : `'${T}'`)\n : [T] extends [[]] ? \"[]\"\n : [T] extends [[any, ...any[]]] ? `[${_ToStringAndJoin<T, \", \">}]`\n : [T] extends [(infer E)[]] ? `${TypeToString<E>}[]`\n : [T] extends [Function] ? \"function\"\n : [T] extends [symbol] ? `symbol(${T['description']})`\n : [T] extends [object] ? `{ ${Join<UnionToTuple<{ [K in keyof T]: `${TypeToString<K>}: ${TypeToString<T[K]>}` }[keyof T]>, \", \">} }`\n : \"<unknown-type>\"\nexport type TypeToString<T> = _TypeToStringInner<T> extends `${infer S}` ? S : never;\n\n/**\n * Can be used to create assertions on types. For example, if passed any T other than `true`, the following will\n * show a type error:\n *\n * ```ts\n * typeAssert<T>()(); // the second pair of braces is important!\n * ```\n */\nexport function typeAssert<T>(): (\n IsAny<T> extends true ? TypeAssertionError<`Type assertion failed. Expected true, but got any.`>\n : IsNever<T> extends true ? TypeAssertionError<`Type assertion failed. Expected true, but got never.`>\n : T extends true ? (() => undefined)\n : TypeAssertionError<`Type assertion failed. Expected true, but got: ${TypeToString<T>}`>\n) {\n return (() => undefined) as any;\n}\ntype TypeAssertionError<T> =\n & [T]\n & /* this promise makes sure that if we accidentally forget the second pair of braces, eslint will complain (if we have no-floating-promises enabled) */ Promise<any>;\n\n\ntypeAssertExtends<ReturnType<typeof typeAssert<true>>, () => undefined>()();\ntypeAssertExtends<ReturnType<typeof typeAssert<false>>, TypeAssertionError<`Type assertion failed. Expected true, but got: false`>>()();\ntypeAssertExtends<ReturnType<typeof typeAssert<never>>, TypeAssertionError<`Type assertion failed. Expected true, but got never.`>>()();\ntypeAssertExtends<ReturnType<typeof typeAssert<any>>, TypeAssertionError<`Type assertion failed. Expected true, but got any.`>>()();\n\n/**\n * Functionally equivalent to `typeAssert<T extends S ? true : false>()()`, but with better error messages.\n */\nexport function typeAssertExtends<T, S>(): (\n [T] extends [S] ? (() => undefined) : TypeAssertionError<`Type assertion failed. Expected ${TypeToString<T>} to extend ${TypeToString<S>}`>\n) {\n return (() => undefined) as any;\n}\n\ntypeAssertExtends<ReturnType<typeof typeAssertExtends<never, true>>, () => undefined>()();\ntypeAssertExtends<ReturnType<typeof typeAssertExtends<any, true>>, () => undefined>()();\ntypeAssertExtends<ReturnType<typeof typeAssertExtends<false, false>>, () => undefined>()();\ntypeAssertExtends<ReturnType<typeof typeAssertExtends<\"abc\", string>>, () => undefined>()();\ntypeAssertExtends<ReturnType<typeof typeAssertExtends<{a: 1, b: 123}, {a: number}>>, () => undefined>()();\ntypeAssertExtends<ReturnType<typeof typeAssertExtends<never, never>>, () => undefined>()();\ntypeAssertExtends<ReturnType<typeof typeAssertExtends<true, any>>, () => undefined>()();\n\ntypeAssertExtends<ReturnType<typeof typeAssertExtends<{a: number}, {a: 1}>>, [\"Type assertion failed. Expected { 'a': number } to extend { 'a': 1 }\"]>()();\ntypeAssertExtends<ReturnType<typeof typeAssertExtends<any, never>>, [\"Type assertion failed. Expected any to extend never\"]>()();\ntypeAssertExtends<ReturnType<typeof typeAssertExtends<false, true>>, [\"Type assertion failed. Expected false to extend true\"]>()();\ntypeAssertExtends<ReturnType<typeof typeAssertExtends<false, never>>, [\"Type assertion failed. Expected false to extend never\"]>()();\n\n\nexport function typeAssertIs<T, U>(): (\n IsAny<T> extends true ? (IsAny<U> extends true ? (() => undefined) : TypeAssertionError<`Type assertion failed. Expected ${TypeToString<T>} to be ${TypeToString<U>}`>)\n : IsAny<U> extends true ? TypeAssertionError<`Type assertion failed. Expected ${TypeToString<T>} to be ${TypeToString<U>}`>\n : [T] extends [U] ? ([U] extends [T] ? (() => undefined) : TypeAssertionError<`Type assertion failed. Expected ${TypeToString<T>} to be ${TypeToString<U>}`>)\n : TypeAssertionError<`Type assertion failed. Expected ${TypeToString<T>} to be ${TypeToString<U>}`>\n) {\n return (() => undefined) as any;\n}\n\ntypeAssertExtends<ReturnType<typeof typeAssertIs<\"123\", \"123\">>, () => undefined>()();\ntypeAssertExtends<ReturnType<typeof typeAssertIs<{a: 1}, {a: 1}>>, () => undefined>()();\ntypeAssertExtends<ReturnType<typeof typeAssertIs<DeepPartial<{a: 1}>, {a?: 1}>>, () => undefined>()();\ntypeAssertExtends<ReturnType<typeof typeAssertIs<any, any>>, () => undefined>()();\ntypeAssertExtends<ReturnType<typeof typeAssertIs<never, never>>, () => undefined>()();\ntypeAssertExtends<ReturnType<typeof typeAssertIs<1, any>>, [\"Type assertion failed. Expected 1 to be any\"]>()();\ntypeAssertExtends<ReturnType<typeof typeAssertIs<any, 1>>, [\"Type assertion failed. Expected any to be 1\"]>()();\ntypeAssertExtends<ReturnType<typeof typeAssertIs<false, true>>, [\"Type assertion failed. Expected false to be true\"]>()();\ntypeAssertExtends<ReturnType<typeof typeAssertIs<{a: number}, {a: 1}>>, [\"Type assertion failed. Expected { 'a': number } to be { 'a': 1 }\"]>()();\ntypeAssertExtends<ReturnType<typeof typeAssertIs<any, never>>, [\"Type assertion failed. Expected any to be never\"]>()();\ntypeAssertExtends<ReturnType<typeof typeAssertIs<false, true>>, [\"Type assertion failed. Expected false to be true\"]>()();\ntypeAssertExtends<ReturnType<typeof typeAssertIs<false, never>>, [\"Type assertion failed. Expected false to be never\"]>()();\n"],"mappings":";AAgDA,aAA6F,EAAE;AAC/F,aAA0F,EAAE;AAe5F,aAAqE,EAAE;AAkEhE,SAAS,aAKd;AACA,SAAQ,MAAM;AAChB;AAMA,kBAAwE,EAAE;AAC1E,kBAAoI,EAAE;AACtI,kBAAoI,EAAE;AACtI,kBAAgI,EAAE;AAK3H,SAAS,oBAEd;AACA,SAAQ,MAAM;AAChB;AAEA,kBAAsF,EAAE;AACxF,kBAAoF,EAAE;AACtF,kBAAuF,EAAE;AACzF,kBAAwF,EAAE;AAC1F,kBAAsG,EAAE;AACxG,kBAAuF,EAAE;AACzF,kBAAoF,EAAE;AAEtF,kBAAuJ,EAAE;AACzJ,kBAA6H,EAAE;AAC/H,kBAA+H,EAAE;AACjI,kBAAiI,EAAE;AAG5H,SAAS,eAKd;AACA,SAAQ,MAAM;AAChB;AAEA,kBAAkF,EAAE;AACpF,kBAAoF,EAAE;AACtF,kBAAkG,EAAE;AACpG,kBAA8E,EAAE;AAChF,kBAAkF,EAAE;AACpF,kBAA4G,EAAE;AAC9G,kBAA4G,EAAE;AAC9G,kBAAsH,EAAE;AACxH,kBAA8I,EAAE;AAChJ,kBAAoH,EAAE;AACtH,kBAAsH,EAAE;AACxH,kBAAwH,EAAE;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/types.tsx"],"sourcesContent":["import { DeepPartial } from \"./objects\";\nimport { Join } from \"./strings\";\n\nexport type IsAny<T> = 0 extends (1 & T) ? true : false;\nexport type IsNever<T> = [T] extends [never] ? true : false;\nexport type IsNullish<T> = [T] extends [null | undefined] ? true : false;\nexport type IsUnion<T, U = T> =\n IsNever<T> extends true ? false\n : IsAny<T> extends true ? false\n : T extends U // distributive conditional https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types\n ? /* if the *whole* original type (`U`) still fits inside the current variant, then `T` wasn’t a union */ ([U] extends [T] ? false : true)\n : never;\n\nexport type NullishCoalesce<T, U> = T extends null | undefined ? U : T;\n\nexport type LastUnionElement<U> = UnionToIntersection<U extends any ? (x: U) => 0 : never> extends (x: infer L) => 0 ? L & U : never;\n\n/**\n * Makes a type prettier by recursively expanding all object types. For example, `Omit<{ a: 1 }, \"a\">` becomes just `{}`.\n */\nexport type Expand<T> = T extends (...args: infer A) => infer R\n ? (\n ((...args: A) => R) extends T\n ? (...args: Expand<A>) => Expand<R>\n : ((...args: Expand<A>) => Expand<R>) & { [K in keyof T]: Expand<T[K]> }\n )\n : (\n T extends object\n ? { [K in keyof T]: Expand<T[K]> }\n : T\n );\n\n\n/**\n * Removes all optional undefined/never keys from an object.\n */\nexport type DeepRemoveOptionalUndefined<T> = T extends object ? { [K in keyof T]: DeepRemoveOptionalUndefined<T[K]> } : T;\n\n// why this works: https://stackoverflow.com/a/50375286\nexport type UnionToIntersection<U> =\n (U extends any ? (x: U) => void : never) extends ((x: infer I) => void) ? I : never\n\ntype _UnionToTupleInner<U, R extends any[], Last> = UnionToTuple<Exclude<U, Last>, [...R, Last]>\nexport type UnionToTuple<U, R extends any[] = []> = [U] extends [never] ? R : _UnionToTupleInner<U, R, LastUnionElement<U>>;\n\nexport type CollapseObjectUnion<T extends object> = {\n [K in AllUnionKeys<T>]?: T extends Record<K, infer V> ? V : never;\n};\ntypeAssertIs<CollapseObjectUnion<{ a: string } | { b: number }>, { a?: string, b?: number }>()();\ntypeAssertIs<CollapseObjectUnion<{ a: string } | { a: number }>, { a?: string | number }>()();\n\nexport type IntersectAll<T extends any[]> = UnionToIntersection<T[number]>;\n\nexport type OptionalKeys<T> = {\n [K in keyof T]: {} extends Pick<T, K> ? K : never;\n}[keyof T];\nexport type RequiredKeys<T> = {\n [K in keyof T]: {} extends Pick<T, K> ? never : K;\n}[keyof T];\n\n/**\n * Returns a type whose keys are the intersection of the keys of T and U, deeply.\n */\nexport type KeyIntersect<T, U> =\n | { [K in keyof T & keyof U]?: T[K] & U[K] }\n | { [K in RequiredKeys<T> & keyof U]: T[K] & U[K] }\n | { [K in RequiredKeys<U> & keyof T]: U[K] & T[K] }\n\n/**\n * Returns ALL keys of all union elements.\n */\nexport type AllUnionKeys<T extends object> = T extends T ? keyof T : never;\ntypeAssertIs<AllUnionKeys<{ a: string } | { b: number }>, \"a\" | \"b\">()();\n\nexport type SubtractType<T, U> = T extends object ? { [K in keyof T]: K extends keyof U ? SubtractType<T[K], U[K]> : T[K] } : (T extends U ? never : T); // note: this only works due to the distributive property of conditional types https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types\n\n\ntype _AntiIntersectInner<T, U> = T extends object ? (\n & Omit<U, keyof T>\n & { [K in keyof Pick<U, { [K in keyof T & keyof U]: U[K] extends T[K] ? (T[K] extends U[K] ? never : K) : never }[keyof T & keyof U]>]: PseudoAntiIntersect<T[K], U[K]> }\n & { [K in keyof Pick<U, keyof T & keyof U>]?: PseudoAntiIntersect<T[K], U[K]> }\n) : U;\n/**\n * Returns a type R such that T & R = U.\n */\nexport type AntiIntersect<T, U> = U extends T ? _AntiIntersectInner<T, U> : \"Cannot anti-intersect a type with a type that is not a subtype of it\"; // NOTE: This type is mostly untested — not sure how well it works on the edge cases\nexport type PseudoAntiIntersect<T, U> = _AntiIntersectInner<T, T & U>;\n\n/**\n * A variation of TypeScript's conditionals with slightly different semantics. It is the perfect type for cases where:\n *\n * - If all possible values are contained in `Extends`, then it will be mapped to `Then`.\n * - If all possible values are not contained in `Extends`, then it will be mapped to `Otherwise`.\n * - If some possible values are contained in `Extends` and some are not, then it will be mapped to `Then | Otherwise`.\n *\n * This is different from TypeScript's built-in conditional types (`Value extends Extends ? Then : Otherwise`), which\n * returns `Otherwise` for the third case (causing unsoundness in many real-world cases).\n */\nexport type IfAndOnlyIf<Value, Extends, Then, Otherwise> =\n | (Value extends Extends ? never : Otherwise)\n | (Value & Extends extends never ? never : Then);\n\n\n/**\n * Can be used to prettify a type in the IDE; for example, some complicated intersected types can be flattened into a single type.\n */\nexport type PrettifyType<T> = T extends object ? { [K in keyof T]: T[K] } & {} : T;\n\ntype _ToStringAndJoin<T extends any[], Separator extends string> =\n T extends [infer U, ...infer Rest extends any[]]\n ? `${TypeToString<U>}${Rest extends [any, ...any[]] ? `${Separator}${_ToStringAndJoin<Rest, Separator>}` : \"\"}`\n : \"<error-joining-tuple-elements>\";\ntype _TypeToStringInner<T> =\n IsAny<T> extends true ? \"any\"\n : IsNever<T> extends true ? \"never\"\n : IsUnion<T> extends true ? _ToStringAndJoin<UnionToTuple<T>, \" | \">\n : [T] extends [number] ? (number extends T ? \"number\" : `${T}`)\n : [T] extends [boolean] ? `${T}`\n : [T] extends [undefined] ? \"undefined\"\n : [T] extends [null] ? \"null\"\n : [T] extends [string] ? (string extends T ? \"string\" : `'${T}'`)\n : [T] extends [[]] ? \"[]\"\n : [T] extends [[any, ...any[]]] ? `[${_ToStringAndJoin<T, \", \">}]`\n : [T] extends [(infer E)[]] ? `${TypeToString<E>}[]`\n : [T] extends [Function] ? \"function\"\n : [T] extends [symbol] ? `symbol(${T['description']})`\n : [T] extends [object] ? `{ ${Join<UnionToTuple<{ [K in keyof T]: `${TypeToString<K>}: ${TypeToString<T[K]>}` }[keyof T]>, \", \">} }`\n : \"<unknown-type>\"\nexport type TypeToString<T> = _TypeToStringInner<T> extends `${infer S}` ? S : never;\n\n/**\n * Can be used to create assertions on types. For example, if passed any T other than `true`, the following will\n * show a type error:\n *\n * ```ts\n * typeAssert<T>()(); // the second pair of braces is important!\n * ```\n */\nexport function typeAssert<T>(): (\n IsAny<T> extends true ? TypeAssertionError<`Type assertion failed. Expected true, but got any.`>\n : IsNever<T> extends true ? TypeAssertionError<`Type assertion failed. Expected true, but got never.`>\n : T extends true ? (() => undefined)\n : TypeAssertionError<`Type assertion failed. Expected true, but got: ${TypeToString<T>}`>\n) {\n return (() => undefined) as any;\n}\ntype TypeAssertionError<T> =\n & [T]\n & /* this promise makes sure that if we accidentally forget the second pair of braces, eslint will complain (if we have no-floating-promises enabled) */ Promise<any>;\n\n\ntypeAssertExtends<ReturnType<typeof typeAssert<true>>, () => undefined>()();\ntypeAssertExtends<ReturnType<typeof typeAssert<false>>, TypeAssertionError<`Type assertion failed. Expected true, but got: false`>>()();\ntypeAssertExtends<ReturnType<typeof typeAssert<never>>, TypeAssertionError<`Type assertion failed. Expected true, but got never.`>>()();\ntypeAssertExtends<ReturnType<typeof typeAssert<any>>, TypeAssertionError<`Type assertion failed. Expected true, but got any.`>>()();\n\n/**\n * Functionally equivalent to `typeAssert<T extends S ? true : false>()()`, but with better error messages.\n */\nexport function typeAssertExtends<T, S>(): (\n [T] extends [S] ? (() => undefined) : TypeAssertionError<`Type assertion failed. Expected ${TypeToString<T>} to extend ${TypeToString<S>}`>\n) {\n return (() => undefined) as any;\n}\n\ntypeAssertExtends<ReturnType<typeof typeAssertExtends<never, true>>, () => undefined>()();\ntypeAssertExtends<ReturnType<typeof typeAssertExtends<any, true>>, () => undefined>()();\ntypeAssertExtends<ReturnType<typeof typeAssertExtends<false, false>>, () => undefined>()();\ntypeAssertExtends<ReturnType<typeof typeAssertExtends<\"abc\", string>>, () => undefined>()();\ntypeAssertExtends<ReturnType<typeof typeAssertExtends<{a: 1, b: 123}, {a: number}>>, () => undefined>()();\ntypeAssertExtends<ReturnType<typeof typeAssertExtends<never, never>>, () => undefined>()();\ntypeAssertExtends<ReturnType<typeof typeAssertExtends<true, any>>, () => undefined>()();\n\ntypeAssertExtends<ReturnType<typeof typeAssertExtends<{a: number}, {a: 1}>>, [\"Type assertion failed. Expected { 'a': number } to extend { 'a': 1 }\"]>()();\ntypeAssertExtends<ReturnType<typeof typeAssertExtends<any, never>>, [\"Type assertion failed. Expected any to extend never\"]>()();\ntypeAssertExtends<ReturnType<typeof typeAssertExtends<false, true>>, [\"Type assertion failed. Expected false to extend true\"]>()();\ntypeAssertExtends<ReturnType<typeof typeAssertExtends<false, never>>, [\"Type assertion failed. Expected false to extend never\"]>()();\n\n\nexport function typeAssertIs<T, U>(): (\n IsAny<T> extends true ? (IsAny<U> extends true ? (() => undefined) : TypeAssertionError<`Type assertion failed. Expected ${TypeToString<T>} to be ${TypeToString<U>}`>)\n : IsAny<U> extends true ? TypeAssertionError<`Type assertion failed. Expected ${TypeToString<T>} to be ${TypeToString<U>}`>\n : [T] extends [U] ? ([U] extends [T] ? (() => undefined) : TypeAssertionError<`Type assertion failed. Expected ${TypeToString<T>} to be ${TypeToString<U>}`>)\n : TypeAssertionError<`Type assertion failed. Expected ${TypeToString<T>} to be ${TypeToString<U>}`>\n) {\n return (() => undefined) as any;\n}\n\ntypeAssertExtends<ReturnType<typeof typeAssertIs<\"123\", \"123\">>, () => undefined>()();\ntypeAssertExtends<ReturnType<typeof typeAssertIs<{a: 1}, {a: 1}>>, () => undefined>()();\ntypeAssertExtends<ReturnType<typeof typeAssertIs<DeepPartial<{a: 1}>, {a?: 1}>>, () => undefined>()();\ntypeAssertExtends<ReturnType<typeof typeAssertIs<any, any>>, () => undefined>()();\ntypeAssertExtends<ReturnType<typeof typeAssertIs<never, never>>, () => undefined>()();\ntypeAssertExtends<ReturnType<typeof typeAssertIs<1, any>>, [\"Type assertion failed. Expected 1 to be any\"]>()();\ntypeAssertExtends<ReturnType<typeof typeAssertIs<any, 1>>, [\"Type assertion failed. Expected any to be 1\"]>()();\ntypeAssertExtends<ReturnType<typeof typeAssertIs<false, true>>, [\"Type assertion failed. Expected false to be true\"]>()();\ntypeAssertExtends<ReturnType<typeof typeAssertIs<{a: number}, {a: 1}>>, [\"Type assertion failed. Expected { 'a': number } to be { 'a': 1 }\"]>()();\ntypeAssertExtends<ReturnType<typeof typeAssertIs<any, never>>, [\"Type assertion failed. Expected any to be never\"]>()();\ntypeAssertExtends<ReturnType<typeof typeAssertIs<false, true>>, [\"Type assertion failed. Expected false to be true\"]>()();\ntypeAssertExtends<ReturnType<typeof typeAssertIs<false, never>>, [\"Type assertion failed. Expected false to be never\"]>()();\n"],"mappings":";AAgDA,aAA6F,EAAE;AAC/F,aAA0F,EAAE;AAuB5F,aAAqE,EAAE;AAkEhE,SAAS,aAKd;AACA,SAAQ,MAAM;AAChB;AAMA,kBAAwE,EAAE;AAC1E,kBAAoI,EAAE;AACtI,kBAAoI,EAAE;AACtI,kBAAgI,EAAE;AAK3H,SAAS,oBAEd;AACA,SAAQ,MAAM;AAChB;AAEA,kBAAsF,EAAE;AACxF,kBAAoF,EAAE;AACtF,kBAAuF,EAAE;AACzF,kBAAwF,EAAE;AAC1F,kBAAsG,EAAE;AACxG,kBAAuF,EAAE;AACzF,kBAAoF,EAAE;AAEtF,kBAAuJ,EAAE;AACzJ,kBAA6H,EAAE;AAC/H,kBAA+H,EAAE;AACjI,kBAAiI,EAAE;AAG5H,SAAS,eAKd;AACA,SAAQ,MAAM;AAChB;AAEA,kBAAkF,EAAE;AACpF,kBAAoF,EAAE;AACtF,kBAAkG,EAAE;AACpG,kBAA8E,EAAE;AAChF,kBAAkF,EAAE;AACpF,kBAA4G,EAAE;AAC9G,kBAA4G,EAAE;AAC9G,kBAAsH,EAAE;AACxH,kBAA8I,EAAE;AAChJ,kBAAoH,EAAE;AACtH,kBAAsH,EAAE;AACxH,kBAAwH,EAAE;","names":[]}
|
package/dist/esm/utils/urls.js
CHANGED
|
@@ -12,10 +12,62 @@ function isValidUrl(url2) {
|
|
|
12
12
|
return !!createUrlIfValid(url2);
|
|
13
13
|
}
|
|
14
14
|
function isValidHostname(hostname) {
|
|
15
|
+
if (!hostname || hostname.startsWith(".") || hostname.endsWith(".") || hostname.includes("..")) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
15
18
|
const url2 = createUrlIfValid(`https://${hostname}`);
|
|
16
19
|
if (!url2) return false;
|
|
17
20
|
return url2.hostname === hostname;
|
|
18
21
|
}
|
|
22
|
+
function isValidHostnameWithWildcards(hostname) {
|
|
23
|
+
if (!hostname) return false;
|
|
24
|
+
const hasWildcard = hostname.includes("*");
|
|
25
|
+
if (!hasWildcard) {
|
|
26
|
+
return isValidHostname(hostname);
|
|
27
|
+
}
|
|
28
|
+
if (hostname.startsWith(".") || hostname.endsWith(".")) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
if (hostname.includes("..")) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
const testHostname = hostname.replace(/\*+/g, "wildcard");
|
|
35
|
+
if (!/^[a-zA-Z0-9.-]+$/.test(testHostname)) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
const segments = hostname.split(/\*+/);
|
|
39
|
+
for (let i = 0; i < segments.length; i++) {
|
|
40
|
+
const segment = segments[i];
|
|
41
|
+
if (segment === "") continue;
|
|
42
|
+
if (i === 0 && segment.startsWith(".")) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
if (i === segments.length - 1 && segment.endsWith(".")) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
if (segment.includes("..")) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
function matchHostnamePattern(pattern, hostname) {
|
|
55
|
+
if (!pattern.includes("*")) {
|
|
56
|
+
return pattern === hostname;
|
|
57
|
+
}
|
|
58
|
+
let regexPattern = pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&");
|
|
59
|
+
const doubleWildcardPlaceholder = "\0DOUBLE_WILDCARD\0";
|
|
60
|
+
regexPattern = regexPattern.replace(/\*\*/g, doubleWildcardPlaceholder);
|
|
61
|
+
regexPattern = regexPattern.replace(/\*/g, "[^.]*");
|
|
62
|
+
regexPattern = regexPattern.replace(new RegExp(doubleWildcardPlaceholder, "g"), ".*");
|
|
63
|
+
regexPattern = "^" + regexPattern + "$";
|
|
64
|
+
try {
|
|
65
|
+
const regex = new RegExp(regexPattern);
|
|
66
|
+
return regex.test(hostname);
|
|
67
|
+
} catch {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
19
71
|
function isLocalhost(urlOrString) {
|
|
20
72
|
const url2 = createUrlIfValid(urlOrString);
|
|
21
73
|
if (!url2) return false;
|
|
@@ -46,7 +98,9 @@ export {
|
|
|
46
98
|
isLocalhost,
|
|
47
99
|
isRelative,
|
|
48
100
|
isValidHostname,
|
|
101
|
+
isValidHostnameWithWildcards,
|
|
49
102
|
isValidUrl,
|
|
103
|
+
matchHostnamePattern,
|
|
50
104
|
url,
|
|
51
105
|
urlString
|
|
52
106
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/urls.tsx"],"sourcesContent":["import { generateSecureRandomString } from \"./crypto\";\nimport { templateIdentity } from \"./strings\";\n\nexport function createUrlIfValid(...args: ConstructorParameters<typeof URL>) {\n try {\n return new URL(...args);\n } catch (e) {\n return null;\n }\n}\nundefined?.test(\"createUrlIfValid\", ({ expect }) => {\n // Test with valid URLs\n expect(createUrlIfValid(\"https://example.com\")).toBeInstanceOf(URL);\n expect(createUrlIfValid(\"https://example.com/path?query=value#hash\")).toBeInstanceOf(URL);\n expect(createUrlIfValid(\"/path\", \"https://example.com\")).toBeInstanceOf(URL);\n\n // Test with invalid URLs\n expect(createUrlIfValid(\"\")).toBeNull();\n expect(createUrlIfValid(\"not a url\")).toBeNull();\n expect(createUrlIfValid(\"http://\")).toBeNull();\n});\n\nexport function isValidUrl(url: string) {\n return !!createUrlIfValid(url);\n}\nundefined?.test(\"isValidUrl\", ({ expect }) => {\n // Test with valid URLs\n expect(isValidUrl(\"https://example.com\")).toBe(true);\n expect(isValidUrl(\"http://localhost:3000\")).toBe(true);\n expect(isValidUrl(\"ftp://example.com\")).toBe(true);\n\n // Test with invalid URLs\n expect(isValidUrl(\"\")).toBe(false);\n expect(isValidUrl(\"not a url\")).toBe(false);\n expect(isValidUrl(\"http://\")).toBe(false);\n});\n\nexport function isValidHostname(hostname: string) {\n const url = createUrlIfValid(`https://${hostname}`);\n if (!url) return false;\n return url.hostname === hostname;\n}\nundefined?.test(\"isValidHostname\", ({ expect }) => {\n // Test with valid hostnames\n expect(isValidHostname(\"example.com\")).toBe(true);\n expect(isValidHostname(\"localhost\")).toBe(true);\n expect(isValidHostname(\"sub.domain.example.com\")).toBe(true);\n expect(isValidHostname(\"127.0.0.1\")).toBe(true);\n\n // Test with invalid hostnames\n expect(isValidHostname(\"\")).toBe(false);\n expect(isValidHostname(\"example.com/path\")).toBe(false);\n expect(isValidHostname(\"https://example.com\")).toBe(false);\n expect(isValidHostname(\"example com\")).toBe(false);\n});\n\nexport function isLocalhost(urlOrString: string | URL) {\n const url = createUrlIfValid(urlOrString);\n if (!url) return false;\n if (url.hostname === \"localhost\" || url.hostname.endsWith(\".localhost\")) return true;\n if (url.hostname.match(/^127\\.\\d+\\.\\d+\\.\\d+$/)) return true;\n return false;\n}\nundefined?.test(\"isLocalhost\", ({ expect }) => {\n // Test with localhost URLs\n expect(isLocalhost(\"http://localhost\")).toBe(true);\n expect(isLocalhost(\"https://localhost:8080\")).toBe(true);\n expect(isLocalhost(\"http://sub.localhost\")).toBe(true);\n expect(isLocalhost(\"http://127.0.0.1\")).toBe(true);\n expect(isLocalhost(\"http://127.1.2.3\")).toBe(true);\n\n // Test with non-localhost URLs\n expect(isLocalhost(\"https://example.com\")).toBe(false);\n expect(isLocalhost(\"http://192.168.1.1\")).toBe(false);\n expect(isLocalhost(\"http://10.0.0.1\")).toBe(false);\n\n // Test with URL objects\n expect(isLocalhost(new URL(\"http://localhost\"))).toBe(true);\n expect(isLocalhost(new URL(\"https://example.com\"))).toBe(false);\n\n // Test with invalid URLs\n expect(isLocalhost(\"not a url\")).toBe(false);\n expect(isLocalhost(\"\")).toBe(false);\n});\n\nexport function isRelative(url: string) {\n const randomDomain = `${generateSecureRandomString()}.stack-auth.example.com`;\n const u = createUrlIfValid(url, `https://${randomDomain}`);\n if (!u) return false;\n if (u.host !== randomDomain) return false;\n if (u.protocol !== \"https:\") return false;\n return true;\n}\nundefined?.test(\"isRelative\", ({ expect }) => {\n // We can't easily mock generateSecureRandomString in this context\n // but we can still test the function's behavior\n\n // Test with relative URLs\n expect(isRelative(\"/\")).toBe(true);\n expect(isRelative(\"/path\")).toBe(true);\n expect(isRelative(\"/path?query=value#hash\")).toBe(true);\n\n // Test with absolute URLs\n expect(isRelative(\"https://example.com\")).toBe(false);\n expect(isRelative(\"http://example.com\")).toBe(false);\n expect(isRelative(\"//example.com\")).toBe(false);\n\n // Note: The implementation treats empty strings and invalid URLs as relative\n // This is because they can be resolved against a base URL\n expect(isRelative(\"\")).toBe(true);\n expect(isRelative(\"not a url\")).toBe(true);\n});\n\nexport function getRelativePart(url: URL) {\n return url.pathname + url.search + url.hash;\n}\nundefined?.test(\"getRelativePart\", ({ expect }) => {\n // Test with various URLs\n expect(getRelativePart(new URL(\"https://example.com\"))).toBe(\"/\");\n expect(getRelativePart(new URL(\"https://example.com/path\"))).toBe(\"/path\");\n expect(getRelativePart(new URL(\"https://example.com/path?query=value\"))).toBe(\"/path?query=value\");\n expect(getRelativePart(new URL(\"https://example.com/path#hash\"))).toBe(\"/path#hash\");\n expect(getRelativePart(new URL(\"https://example.com/path?query=value#hash\"))).toBe(\"/path?query=value#hash\");\n\n // Test with different domains but same paths\n const url1 = new URL(\"https://example.com/path?query=value#hash\");\n const url2 = new URL(\"https://different.com/path?query=value#hash\");\n expect(getRelativePart(url1)).toBe(getRelativePart(url2));\n});\n\n/**\n * A template literal tag that returns a URL.\n *\n * Any values passed are encoded.\n */\nexport function url(strings: TemplateStringsArray | readonly string[], ...values: (string|number|boolean)[]): URL {\n return new URL(urlString(strings, ...values));\n}\nundefined?.test(\"url\", ({ expect }) => {\n // Test with no interpolation\n expect(url`https://example.com`).toBeInstanceOf(URL);\n expect(url`https://example.com`.href).toBe(\"https://example.com/\");\n\n // Test with string interpolation\n expect(url`https://example.com/${\"path\"}`).toBeInstanceOf(URL);\n expect(url`https://example.com/${\"path\"}`.pathname).toBe(\"/path\");\n\n // Test with number interpolation\n expect(url`https://example.com/${42}`).toBeInstanceOf(URL);\n expect(url`https://example.com/${42}`.pathname).toBe(\"/42\");\n\n // Test with boolean interpolation\n expect(url`https://example.com/${true}`).toBeInstanceOf(URL);\n expect(url`https://example.com/${true}`.pathname).toBe(\"/true\");\n\n // Test with special characters in interpolation\n expect(url`https://example.com/${\"path with spaces\"}`).toBeInstanceOf(URL);\n expect(url`https://example.com/${\"path with spaces\"}`.pathname).toBe(\"/path%20with%20spaces\");\n\n // Test with multiple interpolations\n expect(url`https://example.com/${\"path\"}?query=${\"value\"}`).toBeInstanceOf(URL);\n expect(url`https://example.com/${\"path\"}?query=${\"value\"}`.pathname).toBe(\"/path\");\n expect(url`https://example.com/${\"path\"}?query=${\"value\"}`.search).toBe(\"?query=value\");\n});\n\n\n/**\n * A template literal tag that returns a URL string.\n *\n * Any values passed are encoded.\n */\nexport function urlString(strings: TemplateStringsArray | readonly string[], ...values: (string|number|boolean)[]): string {\n return templateIdentity(strings, ...values.map(encodeURIComponent));\n}\nundefined?.test(\"urlString\", ({ expect }) => {\n // Test with no interpolation\n expect(urlString`https://example.com`).toBe(\"https://example.com\");\n\n // Test with string interpolation\n expect(urlString`https://example.com/${\"path\"}`).toBe(\"https://example.com/path\");\n\n // Test with number interpolation\n expect(urlString`https://example.com/${42}`).toBe(\"https://example.com/42\");\n\n // Test with boolean interpolation\n expect(urlString`https://example.com/${true}`).toBe(\"https://example.com/true\");\n\n // Test with special characters in interpolation\n expect(urlString`https://example.com/${\"path with spaces\"}`).toBe(\"https://example.com/path%20with%20spaces\");\n expect(urlString`https://example.com/${\"?&=\"}`).toBe(\"https://example.com/%3F%26%3D\");\n\n // Test with multiple interpolations\n expect(urlString`https://example.com/${\"path\"}?query=${\"value\"}`).toBe(\"https://example.com/path?query=value\");\n expect(urlString`https://example.com/${\"path\"}?query=${\"value with spaces\"}`).toBe(\"https://example.com/path?query=value%20with%20spaces\");\n});\n\n\n"],"mappings":";AAAA,SAAS,kCAAkC;AAC3C,SAAS,wBAAwB;AAE1B,SAAS,oBAAoB,MAAyC;AAC3E,MAAI;AACF,WAAO,IAAI,IAAI,GAAG,IAAI;AAAA,EACxB,SAAS,GAAG;AACV,WAAO;AAAA,EACT;AACF;AAaO,SAAS,WAAWA,MAAa;AACtC,SAAO,CAAC,CAAC,iBAAiBA,IAAG;AAC/B;AAaO,SAAS,gBAAgB,UAAkB;AAChD,QAAMA,OAAM,iBAAiB,WAAW,QAAQ,EAAE;AAClD,MAAI,CAACA,KAAK,QAAO;AACjB,SAAOA,KAAI,aAAa;AAC1B;AAeO,SAAS,YAAY,aAA2B;AACrD,QAAMA,OAAM,iBAAiB,WAAW;AACxC,MAAI,CAACA,KAAK,QAAO;AACjB,MAAIA,KAAI,aAAa,eAAeA,KAAI,SAAS,SAAS,YAAY,EAAG,QAAO;AAChF,MAAIA,KAAI,SAAS,MAAM,sBAAsB,EAAG,QAAO;AACvD,SAAO;AACT;AAuBO,SAAS,WAAWA,MAAa;AACtC,QAAM,eAAe,GAAG,2BAA2B,CAAC;AACpD,QAAM,IAAI,iBAAiBA,MAAK,WAAW,YAAY,EAAE;AACzD,MAAI,CAAC,EAAG,QAAO;AACf,MAAI,EAAE,SAAS,aAAc,QAAO;AACpC,MAAI,EAAE,aAAa,SAAU,QAAO;AACpC,SAAO;AACT;AAqBO,SAAS,gBAAgBA,MAAU;AACxC,SAAOA,KAAI,WAAWA,KAAI,SAASA,KAAI;AACzC;AAoBO,SAAS,IAAI,YAAsD,QAAwC;AAChH,SAAO,IAAI,IAAI,UAAU,SAAS,GAAG,MAAM,CAAC;AAC9C;AAkCO,SAAS,UAAU,YAAsD,QAA2C;AACzH,SAAO,iBAAiB,SAAS,GAAG,OAAO,IAAI,kBAAkB,CAAC;AACpE;","names":["url"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/urls.tsx"],"sourcesContent":["import { generateSecureRandomString } from \"./crypto\";\nimport { templateIdentity } from \"./strings\";\n\nexport function createUrlIfValid(...args: ConstructorParameters<typeof URL>) {\n try {\n return new URL(...args);\n } catch (e) {\n return null;\n }\n}\nundefined?.test(\"createUrlIfValid\", ({ expect }) => {\n // Test with valid URLs\n expect(createUrlIfValid(\"https://example.com\")).toBeInstanceOf(URL);\n expect(createUrlIfValid(\"https://example.com/path?query=value#hash\")).toBeInstanceOf(URL);\n expect(createUrlIfValid(\"/path\", \"https://example.com\")).toBeInstanceOf(URL);\n\n // Test with invalid URLs\n expect(createUrlIfValid(\"\")).toBeNull();\n expect(createUrlIfValid(\"not a url\")).toBeNull();\n expect(createUrlIfValid(\"http://\")).toBeNull();\n});\n\nexport function isValidUrl(url: string) {\n return !!createUrlIfValid(url);\n}\nundefined?.test(\"isValidUrl\", ({ expect }) => {\n // Test with valid URLs\n expect(isValidUrl(\"https://example.com\")).toBe(true);\n expect(isValidUrl(\"http://localhost:3000\")).toBe(true);\n expect(isValidUrl(\"ftp://example.com\")).toBe(true);\n\n // Test with invalid URLs\n expect(isValidUrl(\"\")).toBe(false);\n expect(isValidUrl(\"not a url\")).toBe(false);\n expect(isValidUrl(\"http://\")).toBe(false);\n});\n\nexport function isValidHostname(hostname: string) {\n // Basic validation\n if (!hostname || hostname.startsWith('.') || hostname.endsWith('.') || hostname.includes('..')) {\n return false;\n }\n\n const url = createUrlIfValid(`https://${hostname}`);\n if (!url) return false;\n return url.hostname === hostname;\n}\nundefined?.test(\"isValidHostname\", ({ expect }) => {\n // Test with valid hostnames\n expect(isValidHostname(\"example.com\")).toBe(true);\n expect(isValidHostname(\"localhost\")).toBe(true);\n expect(isValidHostname(\"sub.domain.example.com\")).toBe(true);\n expect(isValidHostname(\"127.0.0.1\")).toBe(true);\n\n // Test with invalid hostnames\n expect(isValidHostname(\"\")).toBe(false);\n expect(isValidHostname(\"example.com/path\")).toBe(false);\n expect(isValidHostname(\"https://example.com\")).toBe(false);\n expect(isValidHostname(\"example com\")).toBe(false);\n});\n\nexport function isValidHostnameWithWildcards(hostname: string) {\n // Empty hostnames are invalid\n if (!hostname) return false;\n\n // Check if it contains wildcards\n const hasWildcard = hostname.includes('*');\n\n if (!hasWildcard) {\n // If no wildcards, validate as a normal hostname\n return isValidHostname(hostname);\n }\n\n // Basic validation checks that apply even with wildcards\n // - Hostname cannot start or end with a dot\n if (hostname.startsWith('.') || hostname.endsWith('.')) {\n return false;\n }\n\n // - No consecutive dots\n if (hostname.includes('..')) {\n return false;\n }\n\n // For wildcard validation, check that non-wildcard parts contain valid characters\n // Replace wildcards with a valid placeholder to check the rest\n const testHostname = hostname.replace(/\\*+/g, 'wildcard');\n\n // Check if the resulting string would be a valid hostname\n if (!/^[a-zA-Z0-9.-]+$/.test(testHostname)) {\n return false;\n }\n\n // Additional check: ensure the pattern makes sense\n // Check each segment between wildcards\n const segments = hostname.split(/\\*+/);\n for (let i = 0; i < segments.length; i++) {\n const segment = segments[i];\n if (segment === '') continue; // Empty segments are OK (consecutive wildcards)\n\n // First segment can't start with dot\n if (i === 0 && segment.startsWith('.')) {\n return false;\n }\n\n // Last segment can't end with dot\n if (i === segments.length - 1 && segment.endsWith('.')) {\n return false;\n }\n\n // No segment should have consecutive dots\n if (segment.includes('..')) {\n return false;\n }\n }\n\n return true;\n}\nundefined?.test(\"isValidHostnameWithWildcards\", ({ expect }) => {\n // Test with valid regular hostnames\n expect(isValidHostnameWithWildcards(\"example.com\")).toBe(true);\n expect(isValidHostnameWithWildcards(\"localhost\")).toBe(true);\n expect(isValidHostnameWithWildcards(\"sub.domain.example.com\")).toBe(true);\n\n // Test with valid wildcard hostnames\n expect(isValidHostnameWithWildcards(\"*.example.com\")).toBe(true);\n expect(isValidHostnameWithWildcards(\"a-*.example.com\")).toBe(true);\n expect(isValidHostnameWithWildcards(\"*.*.org\")).toBe(true);\n expect(isValidHostnameWithWildcards(\"**.example.com\")).toBe(true);\n expect(isValidHostnameWithWildcards(\"sub.**.com\")).toBe(true);\n expect(isValidHostnameWithWildcards(\"*-api.*.com\")).toBe(true);\n\n // Test with invalid hostnames\n expect(isValidHostnameWithWildcards(\"\")).toBe(false);\n expect(isValidHostnameWithWildcards(\"example.com/path\")).toBe(false);\n expect(isValidHostnameWithWildcards(\"https://example.com\")).toBe(false);\n expect(isValidHostnameWithWildcards(\"example com\")).toBe(false);\n expect(isValidHostnameWithWildcards(\".example.com\")).toBe(false);\n expect(isValidHostnameWithWildcards(\"example.com.\")).toBe(false);\n expect(isValidHostnameWithWildcards(\"example..com\")).toBe(false);\n expect(isValidHostnameWithWildcards(\"*.example..com\")).toBe(false);\n});\n\nexport function matchHostnamePattern(pattern: string, hostname: string): boolean {\n // If no wildcards, it's an exact match\n if (!pattern.includes('*')) {\n return pattern === hostname;\n }\n\n // Convert the pattern to a regex\n // First, escape all regex special characters except *\n let regexPattern = pattern.replace(/[.+?^${}()|[\\]\\\\]/g, '\\\\$&');\n\n // Use a placeholder for ** to handle it separately from single *\n const doubleWildcardPlaceholder = '\\x00DOUBLE_WILDCARD\\x00';\n regexPattern = regexPattern.replace(/\\*\\*/g, doubleWildcardPlaceholder);\n\n // Replace single * with a pattern that matches anything except dots\n regexPattern = regexPattern.replace(/\\*/g, '[^.]*');\n\n // Replace the double wildcard placeholder with a pattern that matches anything including dots\n regexPattern = regexPattern.replace(new RegExp(doubleWildcardPlaceholder, 'g'), '.*');\n\n // Anchor the pattern to match the entire hostname\n regexPattern = '^' + regexPattern + '$';\n\n try {\n const regex = new RegExp(regexPattern);\n return regex.test(hostname);\n } catch {\n return false;\n }\n}\nundefined?.test(\"matchHostnamePattern\", ({ expect }) => {\n // Test exact matches\n expect(matchHostnamePattern(\"example.com\", \"example.com\")).toBe(true);\n expect(matchHostnamePattern(\"example.com\", \"other.com\")).toBe(false);\n\n // Test single wildcard matches\n expect(matchHostnamePattern(\"*.example.com\", \"api.example.com\")).toBe(true);\n expect(matchHostnamePattern(\"*.example.com\", \"www.example.com\")).toBe(true);\n expect(matchHostnamePattern(\"*.example.com\", \"example.com\")).toBe(false);\n expect(matchHostnamePattern(\"*.example.com\", \"api.v2.example.com\")).toBe(false);\n\n // Test double wildcard matches\n expect(matchHostnamePattern(\"**.example.com\", \"api.example.com\")).toBe(true);\n expect(matchHostnamePattern(\"**.example.com\", \"api.v2.example.com\")).toBe(true);\n expect(matchHostnamePattern(\"**.example.com\", \"a.b.c.example.com\")).toBe(true);\n expect(matchHostnamePattern(\"**.example.com\", \"example.com\")).toBe(false);\n\n // Test complex patterns\n expect(matchHostnamePattern(\"api-*.example.com\", \"api-v1.example.com\")).toBe(true);\n expect(matchHostnamePattern(\"api-*.example.com\", \"api-v2.example.com\")).toBe(true);\n expect(matchHostnamePattern(\"api-*.example.com\", \"api.example.com\")).toBe(false);\n expect(matchHostnamePattern(\"*.*.org\", \"mail.example.org\")).toBe(true);\n expect(matchHostnamePattern(\"*.*.org\", \"example.org\")).toBe(false);\n});\n\nexport function isLocalhost(urlOrString: string | URL) {\n const url = createUrlIfValid(urlOrString);\n if (!url) return false;\n if (url.hostname === \"localhost\" || url.hostname.endsWith(\".localhost\")) return true;\n if (url.hostname.match(/^127\\.\\d+\\.\\d+\\.\\d+$/)) return true;\n return false;\n}\nundefined?.test(\"isLocalhost\", ({ expect }) => {\n // Test with localhost URLs\n expect(isLocalhost(\"http://localhost\")).toBe(true);\n expect(isLocalhost(\"https://localhost:8080\")).toBe(true);\n expect(isLocalhost(\"http://sub.localhost\")).toBe(true);\n expect(isLocalhost(\"http://127.0.0.1\")).toBe(true);\n expect(isLocalhost(\"http://127.1.2.3\")).toBe(true);\n\n // Test with non-localhost URLs\n expect(isLocalhost(\"https://example.com\")).toBe(false);\n expect(isLocalhost(\"http://192.168.1.1\")).toBe(false);\n expect(isLocalhost(\"http://10.0.0.1\")).toBe(false);\n\n // Test with URL objects\n expect(isLocalhost(new URL(\"http://localhost\"))).toBe(true);\n expect(isLocalhost(new URL(\"https://example.com\"))).toBe(false);\n\n // Test with invalid URLs\n expect(isLocalhost(\"not a url\")).toBe(false);\n expect(isLocalhost(\"\")).toBe(false);\n});\n\nexport function isRelative(url: string) {\n const randomDomain = `${generateSecureRandomString()}.stack-auth.example.com`;\n const u = createUrlIfValid(url, `https://${randomDomain}`);\n if (!u) return false;\n if (u.host !== randomDomain) return false;\n if (u.protocol !== \"https:\") return false;\n return true;\n}\nundefined?.test(\"isRelative\", ({ expect }) => {\n // We can't easily mock generateSecureRandomString in this context\n // but we can still test the function's behavior\n\n // Test with relative URLs\n expect(isRelative(\"/\")).toBe(true);\n expect(isRelative(\"/path\")).toBe(true);\n expect(isRelative(\"/path?query=value#hash\")).toBe(true);\n\n // Test with absolute URLs\n expect(isRelative(\"https://example.com\")).toBe(false);\n expect(isRelative(\"http://example.com\")).toBe(false);\n expect(isRelative(\"//example.com\")).toBe(false);\n\n // Note: The implementation treats empty strings and invalid URLs as relative\n // This is because they can be resolved against a base URL\n expect(isRelative(\"\")).toBe(true);\n expect(isRelative(\"not a url\")).toBe(true);\n});\n\nexport function getRelativePart(url: URL) {\n return url.pathname + url.search + url.hash;\n}\nundefined?.test(\"getRelativePart\", ({ expect }) => {\n // Test with various URLs\n expect(getRelativePart(new URL(\"https://example.com\"))).toBe(\"/\");\n expect(getRelativePart(new URL(\"https://example.com/path\"))).toBe(\"/path\");\n expect(getRelativePart(new URL(\"https://example.com/path?query=value\"))).toBe(\"/path?query=value\");\n expect(getRelativePart(new URL(\"https://example.com/path#hash\"))).toBe(\"/path#hash\");\n expect(getRelativePart(new URL(\"https://example.com/path?query=value#hash\"))).toBe(\"/path?query=value#hash\");\n\n // Test with different domains but same paths\n const url1 = new URL(\"https://example.com/path?query=value#hash\");\n const url2 = new URL(\"https://different.com/path?query=value#hash\");\n expect(getRelativePart(url1)).toBe(getRelativePart(url2));\n});\n\n/**\n * A template literal tag that returns a URL.\n *\n * Any values passed are encoded.\n */\nexport function url(strings: TemplateStringsArray | readonly string[], ...values: (string|number|boolean)[]): URL {\n return new URL(urlString(strings, ...values));\n}\nundefined?.test(\"url\", ({ expect }) => {\n // Test with no interpolation\n expect(url`https://example.com`).toBeInstanceOf(URL);\n expect(url`https://example.com`.href).toBe(\"https://example.com/\");\n\n // Test with string interpolation\n expect(url`https://example.com/${\"path\"}`).toBeInstanceOf(URL);\n expect(url`https://example.com/${\"path\"}`.pathname).toBe(\"/path\");\n\n // Test with number interpolation\n expect(url`https://example.com/${42}`).toBeInstanceOf(URL);\n expect(url`https://example.com/${42}`.pathname).toBe(\"/42\");\n\n // Test with boolean interpolation\n expect(url`https://example.com/${true}`).toBeInstanceOf(URL);\n expect(url`https://example.com/${true}`.pathname).toBe(\"/true\");\n\n // Test with special characters in interpolation\n expect(url`https://example.com/${\"path with spaces\"}`).toBeInstanceOf(URL);\n expect(url`https://example.com/${\"path with spaces\"}`.pathname).toBe(\"/path%20with%20spaces\");\n\n // Test with multiple interpolations\n expect(url`https://example.com/${\"path\"}?query=${\"value\"}`).toBeInstanceOf(URL);\n expect(url`https://example.com/${\"path\"}?query=${\"value\"}`.pathname).toBe(\"/path\");\n expect(url`https://example.com/${\"path\"}?query=${\"value\"}`.search).toBe(\"?query=value\");\n});\n\n\n/**\n * A template literal tag that returns a URL string.\n *\n * Any values passed are encoded.\n */\nexport function urlString(strings: TemplateStringsArray | readonly string[], ...values: (string|number|boolean)[]): string {\n return templateIdentity(strings, ...values.map(encodeURIComponent));\n}\nundefined?.test(\"urlString\", ({ expect }) => {\n // Test with no interpolation\n expect(urlString`https://example.com`).toBe(\"https://example.com\");\n\n // Test with string interpolation\n expect(urlString`https://example.com/${\"path\"}`).toBe(\"https://example.com/path\");\n\n // Test with number interpolation\n expect(urlString`https://example.com/${42}`).toBe(\"https://example.com/42\");\n\n // Test with boolean interpolation\n expect(urlString`https://example.com/${true}`).toBe(\"https://example.com/true\");\n\n // Test with special characters in interpolation\n expect(urlString`https://example.com/${\"path with spaces\"}`).toBe(\"https://example.com/path%20with%20spaces\");\n expect(urlString`https://example.com/${\"?&=\"}`).toBe(\"https://example.com/%3F%26%3D\");\n\n // Test with multiple interpolations\n expect(urlString`https://example.com/${\"path\"}?query=${\"value\"}`).toBe(\"https://example.com/path?query=value\");\n expect(urlString`https://example.com/${\"path\"}?query=${\"value with spaces\"}`).toBe(\"https://example.com/path?query=value%20with%20spaces\");\n});\n\n\n"],"mappings":";AAAA,SAAS,kCAAkC;AAC3C,SAAS,wBAAwB;AAE1B,SAAS,oBAAoB,MAAyC;AA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|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import '../crud.mjs';
|
|
2
2
|
import { KnownErrors } from '../known-errors.mjs';
|
|
3
|
+
import '../schema-fields.mjs';
|
|
3
4
|
import 'yup';
|
|
4
5
|
import '../utils/types.mjs';
|
|
5
6
|
import '../utils/strings.mjs';
|
|
6
7
|
import '../utils/errors.mjs';
|
|
7
8
|
import '../utils/json.mjs';
|
|
8
9
|
import '../utils/results.mjs';
|
|
10
|
+
import '../utils/currencies.mjs';
|
|
11
|
+
import '../utils/dates.mjs';
|
|
9
12
|
|
|
10
13
|
declare function getPasswordError(password: string): KnownErrors["PasswordRequirementsNotMet"] | undefined;
|
|
11
14
|
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import '../crud.js';
|
|
2
2
|
import { KnownErrors } from '../known-errors.js';
|
|
3
|
+
import '../schema-fields.js';
|
|
3
4
|
import 'yup';
|
|
4
5
|
import '../utils/types.js';
|
|
5
6
|
import '../utils/strings.js';
|
|
6
7
|
import '../utils/errors.js';
|
|
7
8
|
import '../utils/json.js';
|
|
8
9
|
import '../utils/results.js';
|
|
10
|
+
import '../utils/currencies.js';
|
|
11
|
+
import '../utils/dates.js';
|
|
9
12
|
|
|
10
13
|
declare function getPasswordError(password: string): KnownErrors["PasswordRequirementsNotMet"] | undefined;
|
|
11
14
|
|
|
@@ -37,7 +37,8 @@ function getProductionModeErrors(project) {
|
|
|
37
37
|
for (const { domain } of project.config.domains) {
|
|
38
38
|
let url;
|
|
39
39
|
try {
|
|
40
|
-
|
|
40
|
+
const normalizedDomain = domain.replace(/\*+/g, "wildcard-placeholder");
|
|
41
|
+
url = new URL(normalizedDomain);
|
|
41
42
|
} catch (e) {
|
|
42
43
|
(0, import_errors.captureError)("production-mode-domain-not-valid", new import_errors.StackAssertionError("Domain was somehow not a valid URL; we should've caught this when setting the domain in the first place", {
|
|
43
44
|
domain,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/helpers/production-mode.ts"],"sourcesContent":["import { ProjectsCrud } from \"../interface/crud/projects\";\nimport { StackAssertionError, captureError } from \"../utils/errors\";\nimport { isLocalhost } from \"../utils/urls\";\n\nexport type ProductionModeError = {\n message: string,\n relativeFixUrl: `/${string}`,\n};\n\nexport function getProductionModeErrors(project: ProjectsCrud[\"Admin\"][\"Read\"]): ProductionModeError[] {\n const errors: ProductionModeError[] = [];\n const domainsFixUrl = `/projects/${project.id}/domains` as const;\n\n if (project.config.allow_localhost) {\n errors.push({\n message: \"Localhost is not allowed in production mode, turn off 'Allow localhost' in project settings\",\n relativeFixUrl: domainsFixUrl,\n });\n }\n\n for (const { domain } of project.config.domains) {\n let url;\n try {\n url = new URL(
|
|
1
|
+
{"version":3,"sources":["../../src/helpers/production-mode.ts"],"sourcesContent":["import { ProjectsCrud } from \"../interface/crud/projects\";\nimport { StackAssertionError, captureError } from \"../utils/errors\";\nimport { isLocalhost } from \"../utils/urls\";\n\nexport type ProductionModeError = {\n message: string,\n relativeFixUrl: `/${string}`,\n};\n\nexport function getProductionModeErrors(project: ProjectsCrud[\"Admin\"][\"Read\"]): ProductionModeError[] {\n const errors: ProductionModeError[] = [];\n const domainsFixUrl = `/projects/${project.id}/domains` as const;\n\n if (project.config.allow_localhost) {\n errors.push({\n message: \"Localhost is not allowed in production mode, turn off 'Allow localhost' in project settings\",\n relativeFixUrl: domainsFixUrl,\n });\n }\n\n for (const { domain } of project.config.domains) {\n let url;\n try {\n // For wildcard domains, replace wildcards with a valid placeholder to validate the URL structure\n const normalizedDomain = domain.replace(/\\*+/g, 'wildcard-placeholder');\n url = new URL(normalizedDomain);\n } catch (e) {\n captureError(\"production-mode-domain-not-valid\", new StackAssertionError(\"Domain was somehow not a valid URL; we should've caught this when setting the domain in the first place\", {\n domain,\n projectId: project\n }));\n errors.push({\n message: \"Trusted domain is not a valid URL: \" + domain,\n relativeFixUrl: domainsFixUrl,\n });\n continue;\n }\n\n if (isLocalhost(url)) {\n errors.push({\n message: \"Localhost domains are not allowed to be trusted in production mode: \" + domain,\n relativeFixUrl: domainsFixUrl,\n });\n } else if (url.hostname.match(/^\\d+(\\.\\d+)*$/)) {\n errors.push({\n message: \"Direct IPs are not valid for trusted domains in production mode: \" + domain,\n relativeFixUrl: domainsFixUrl,\n });\n } else if (url.protocol !== \"https:\") {\n errors.push({\n message: \"Trusted domains should be HTTPS: \" + domain,\n relativeFixUrl: domainsFixUrl,\n });\n }\n }\n\n return errors;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAAkD;AAClD,kBAA4B;AAOrB,SAAS,wBAAwB,SAA+D;AACrG,QAAM,SAAgC,CAAC;AACvC,QAAM,gBAAgB,aAAa,QAAQ,EAAE;AAE7C,MAAI,QAAQ,OAAO,iBAAiB;AAClC,WAAO,KAAK;AAAA,MACV,SAAS;AAAA,MACT,gBAAgB;AAAA,IAClB,CAAC;AAAA,EACH;AAEA,aAAW,EAAE,OAAO,KAAK,QAAQ,OAAO,SAAS;AAC/C,QAAI;AACJ,QAAI;AAEF,YAAM,mBAAmB,OAAO,QAAQ,QAAQ,sBAAsB;AACtE,YAAM,IAAI,IAAI,gBAAgB;AAAA,IAChC,SAAS,GAAG;AACV,sCAAa,oCAAoC,IAAI,kCAAoB,2GAA2G;AAAA,QAClL;AAAA,QACA,WAAW;AAAA,MACb,CAAC,CAAC;AACF,aAAO,KAAK;AAAA,QACV,SAAS,wCAAwC;AAAA,QACjD,gBAAgB;AAAA,MAClB,CAAC;AACD;AAAA,IACF;AAEA,YAAI,yBAAY,GAAG,GAAG;AACpB,aAAO,KAAK;AAAA,QACV,SAAS,yEAAyE;AAAA,QAClF,gBAAgB;AAAA,MAClB,CAAC;AAAA,IACH,WAAW,IAAI,SAAS,MAAM,eAAe,GAAG;AAC9C,aAAO,KAAK;AAAA,QACV,SAAS,sEAAsE;AAAA,QAC/E,gBAAgB;AAAA,MAClB,CAAC;AAAA,IACH,WAAW,IAAI,aAAa,UAAU;AACpC,aAAO,KAAK;AAAA,QACV,SAAS,sCAAsC;AAAA,QAC/C,gBAAgB;AAAA,MAClB,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
package/dist/index.d.mts
CHANGED
|
@@ -19,6 +19,7 @@ import './utils/results.mjs';
|
|
|
19
19
|
import './interface/crud/connected-accounts.mjs';
|
|
20
20
|
import './interface/crud/contact-channels.mjs';
|
|
21
21
|
import './interface/crud/current-user.mjs';
|
|
22
|
+
import './interface/crud/items.mjs';
|
|
22
23
|
import './interface/crud/notification-preferences.mjs';
|
|
23
24
|
import './interface/crud/sessions.mjs';
|
|
24
25
|
import './interface/crud/team-invitation.mjs';
|
|
@@ -28,5 +29,8 @@ import './interface/crud/teams.mjs';
|
|
|
28
29
|
import './interface/crud/users.mjs';
|
|
29
30
|
import './utils/errors.mjs';
|
|
30
31
|
import './utils/json.mjs';
|
|
32
|
+
import './schema-fields.mjs';
|
|
33
|
+
import './utils/currencies.mjs';
|
|
34
|
+
import './utils/dates.mjs';
|
|
31
35
|
import '@simplewebauthn/types';
|
|
32
36
|
import './interface/crud/project-api-keys.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ import './utils/results.js';
|
|
|
19
19
|
import './interface/crud/connected-accounts.js';
|
|
20
20
|
import './interface/crud/contact-channels.js';
|
|
21
21
|
import './interface/crud/current-user.js';
|
|
22
|
+
import './interface/crud/items.js';
|
|
22
23
|
import './interface/crud/notification-preferences.js';
|
|
23
24
|
import './interface/crud/sessions.js';
|
|
24
25
|
import './interface/crud/team-invitation.js';
|
|
@@ -28,5 +29,8 @@ import './interface/crud/teams.js';
|
|
|
28
29
|
import './interface/crud/users.js';
|
|
29
30
|
import './utils/errors.js';
|
|
30
31
|
import './utils/json.js';
|
|
32
|
+
import './schema-fields.js';
|
|
33
|
+
import './utils/currencies.js';
|
|
34
|
+
import './utils/dates.js';
|
|
31
35
|
import '@simplewebauthn/types';
|
|
32
36
|
import './interface/crud/project-api-keys.js';
|
|
@@ -18,6 +18,7 @@ import '../utils/results.mjs';
|
|
|
18
18
|
import './crud/connected-accounts.mjs';
|
|
19
19
|
import './crud/contact-channels.mjs';
|
|
20
20
|
import './crud/current-user.mjs';
|
|
21
|
+
import './crud/items.mjs';
|
|
21
22
|
import './crud/notification-preferences.mjs';
|
|
22
23
|
import './crud/sessions.mjs';
|
|
23
24
|
import './crud/team-invitation.mjs';
|
|
@@ -27,6 +28,9 @@ import './crud/teams.mjs';
|
|
|
27
28
|
import './crud/users.mjs';
|
|
28
29
|
import '../utils/errors.mjs';
|
|
29
30
|
import '../utils/json.mjs';
|
|
31
|
+
import '../schema-fields.mjs';
|
|
32
|
+
import '../utils/currencies.mjs';
|
|
33
|
+
import '../utils/dates.mjs';
|
|
30
34
|
import '@simplewebauthn/types';
|
|
31
35
|
import './crud/project-api-keys.mjs';
|
|
32
36
|
|
|
@@ -93,6 +97,7 @@ declare class StackAdminInterface extends StackServerInterface {
|
|
|
93
97
|
deleteProjectPermissionDefinition(permissionId: string): Promise<void>;
|
|
94
98
|
getSvixToken(): Promise<SvixTokenCrud["Admin"]["Read"]>;
|
|
95
99
|
deleteProject(): Promise<void>;
|
|
100
|
+
transferProject(session: InternalSession, newTeamId: string): Promise<void>;
|
|
96
101
|
getMetrics(): Promise<any>;
|
|
97
102
|
sendTestEmail(data: {
|
|
98
103
|
recipient_email: string;
|
|
@@ -156,15 +161,6 @@ declare class StackAdminInterface extends StackServerInterface {
|
|
|
156
161
|
customer_id: string;
|
|
157
162
|
offer_id: string;
|
|
158
163
|
}): Promise<string>;
|
|
159
|
-
createItemQuantityChange(options: {
|
|
160
|
-
customer_id: string;
|
|
161
|
-
item_id: string;
|
|
162
|
-
quantity: number;
|
|
163
|
-
expires_at?: string;
|
|
164
|
-
description?: string;
|
|
165
|
-
}): Promise<{
|
|
166
|
-
id: string;
|
|
167
|
-
}>;
|
|
168
164
|
}
|
|
169
165
|
|
|
170
166
|
export { type AdminAuthApplicationOptions, type ChatContent, type InternalApiKeyCreateCrudRequest, type InternalApiKeyCreateCrudResponse, StackAdminInterface };
|
|
@@ -18,6 +18,7 @@ import '../utils/results.js';
|
|
|
18
18
|
import './crud/connected-accounts.js';
|
|
19
19
|
import './crud/contact-channels.js';
|
|
20
20
|
import './crud/current-user.js';
|
|
21
|
+
import './crud/items.js';
|
|
21
22
|
import './crud/notification-preferences.js';
|
|
22
23
|
import './crud/sessions.js';
|
|
23
24
|
import './crud/team-invitation.js';
|
|
@@ -27,6 +28,9 @@ import './crud/teams.js';
|
|
|
27
28
|
import './crud/users.js';
|
|
28
29
|
import '../utils/errors.js';
|
|
29
30
|
import '../utils/json.js';
|
|
31
|
+
import '../schema-fields.js';
|
|
32
|
+
import '../utils/currencies.js';
|
|
33
|
+
import '../utils/dates.js';
|
|
30
34
|
import '@simplewebauthn/types';
|
|
31
35
|
import './crud/project-api-keys.js';
|
|
32
36
|
|
|
@@ -93,6 +97,7 @@ declare class StackAdminInterface extends StackServerInterface {
|
|
|
93
97
|
deleteProjectPermissionDefinition(permissionId: string): Promise<void>;
|
|
94
98
|
getSvixToken(): Promise<SvixTokenCrud["Admin"]["Read"]>;
|
|
95
99
|
deleteProject(): Promise<void>;
|
|
100
|
+
transferProject(session: InternalSession, newTeamId: string): Promise<void>;
|
|
96
101
|
getMetrics(): Promise<any>;
|
|
97
102
|
sendTestEmail(data: {
|
|
98
103
|
recipient_email: string;
|
|
@@ -156,15 +161,6 @@ declare class StackAdminInterface extends StackServerInterface {
|
|
|
156
161
|
customer_id: string;
|
|
157
162
|
offer_id: string;
|
|
158
163
|
}): Promise<string>;
|
|
159
|
-
createItemQuantityChange(options: {
|
|
160
|
-
customer_id: string;
|
|
161
|
-
item_id: string;
|
|
162
|
-
quantity: number;
|
|
163
|
-
expires_at?: string;
|
|
164
|
-
description?: string;
|
|
165
|
-
}): Promise<{
|
|
166
|
-
id: string;
|
|
167
|
-
}>;
|
|
168
164
|
}
|
|
169
165
|
|
|
170
166
|
export { type AdminAuthApplicationOptions, type ChatContent, type InternalApiKeyCreateCrudRequest, type InternalApiKeyCreateCrudResponse, StackAdminInterface };
|
|
@@ -219,6 +219,22 @@ var StackAdminInterface = class extends import_server_interface.StackServerInter
|
|
|
219
219
|
null
|
|
220
220
|
);
|
|
221
221
|
}
|
|
222
|
+
async transferProject(session, newTeamId) {
|
|
223
|
+
await this.sendAdminRequest(
|
|
224
|
+
"/internal/projects/transfer",
|
|
225
|
+
{
|
|
226
|
+
method: "POST",
|
|
227
|
+
headers: {
|
|
228
|
+
"content-type": "application/json"
|
|
229
|
+
},
|
|
230
|
+
body: JSON.stringify({
|
|
231
|
+
project_id: this.options.projectId,
|
|
232
|
+
new_team_id: newTeamId
|
|
233
|
+
})
|
|
234
|
+
},
|
|
235
|
+
session
|
|
236
|
+
);
|
|
237
|
+
}
|
|
222
238
|
async getMetrics() {
|
|
223
239
|
const response = await this.sendAdminRequest(
|
|
224
240
|
"/internal/metrics",
|
|
@@ -446,25 +462,6 @@ var StackAdminInterface = class extends import_server_interface.StackServerInter
|
|
|
446
462
|
const result = await response.json();
|
|
447
463
|
return result.url;
|
|
448
464
|
}
|
|
449
|
-
async createItemQuantityChange(options) {
|
|
450
|
-
const response = await this.sendAdminRequest(
|
|
451
|
-
`/payments/items/${options.customer_id}/${options.item_id}`,
|
|
452
|
-
{
|
|
453
|
-
method: "POST",
|
|
454
|
-
headers: {
|
|
455
|
-
"content-type": "application/json"
|
|
456
|
-
},
|
|
457
|
-
body: JSON.stringify({
|
|
458
|
-
quantity: options.quantity,
|
|
459
|
-
expires_at: options.expires_at,
|
|
460
|
-
description: options.description
|
|
461
|
-
})
|
|
462
|
-
},
|
|
463
|
-
null
|
|
464
|
-
);
|
|
465
|
-
const result = await response.json();
|
|
466
|
-
return result;
|
|
467
|
-
}
|
|
468
465
|
};
|
|
469
466
|
// Annotate the CommonJS export names for ESM import in node:
|
|
470
467
|
0 && (module.exports = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/interface/admin-interface.ts"],"sourcesContent":["import { InternalSession } from \"../sessions\";\nimport { ConfigCrud, ConfigOverrideCrud } from \"./crud/config\";\nimport { InternalEmailsCrud } from \"./crud/emails\";\nimport { InternalApiKeysCrud } from \"./crud/internal-api-keys\";\nimport { ProjectPermissionDefinitionsCrud } from \"./crud/project-permissions\";\nimport { ProjectsCrud } from \"./crud/projects\";\nimport { SvixTokenCrud } from \"./crud/svix-token\";\nimport { TeamPermissionDefinitionsCrud } from \"./crud/team-permissions\";\nimport { ServerAuthApplicationOptions, StackServerInterface } from \"./server-interface\";\n\nexport type ChatContent = Array<\n | { type: \"text\", text: string }\n | { type: \"tool-call\", toolName: string, toolCallId: string, args: any, argsText: string, result: any }\n>;\n\nexport type AdminAuthApplicationOptions = ServerAuthApplicationOptions &(\n | {\n superSecretAdminKey: string,\n }\n | {\n projectOwnerSession: InternalSession,\n }\n);\n\nexport type InternalApiKeyCreateCrudRequest = {\n has_publishable_client_key: boolean,\n has_secret_server_key: boolean,\n has_super_secret_admin_key: boolean,\n expires_at_millis: number,\n description: string,\n};\n\nexport type InternalApiKeyCreateCrudResponse = InternalApiKeysCrud[\"Admin\"][\"Read\"] & {\n publishable_client_key?: string,\n secret_server_key?: string,\n super_secret_admin_key?: string,\n};\n\nexport class StackAdminInterface extends StackServerInterface {\n constructor(public readonly options: AdminAuthApplicationOptions) {\n super(options);\n }\n\n public async sendAdminRequest(path: string, options: RequestInit, session: InternalSession | null, requestType: \"admin\" = \"admin\") {\n return await this.sendServerRequest(\n path,\n {\n ...options,\n headers: {\n \"x-stack-super-secret-admin-key\": \"superSecretAdminKey\" in this.options ? this.options.superSecretAdminKey : \"\",\n ...options.headers,\n },\n },\n session,\n requestType,\n );\n }\n\n async getProject(): Promise<ProjectsCrud[\"Admin\"][\"Read\"]> {\n const response = await this.sendAdminRequest(\n \"/internal/projects/current\",\n {\n method: \"GET\",\n },\n null,\n );\n return await response.json();\n }\n\n async updateProject(update: ProjectsCrud[\"Admin\"][\"Update\"]): Promise<ProjectsCrud[\"Admin\"][\"Read\"]> {\n const response = await this.sendAdminRequest(\n \"/internal/projects/current\",\n {\n method: \"PATCH\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify(update),\n },\n null,\n );\n return await response.json();\n }\n\n async createInternalApiKey(\n options: InternalApiKeyCreateCrudRequest,\n ): Promise<InternalApiKeyCreateCrudResponse> {\n const response = await this.sendAdminRequest(\n \"/internal/api-keys\",\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify(options),\n },\n null,\n );\n return await response.json();\n }\n\n async listInternalApiKeys(): Promise<InternalApiKeysCrud[\"Admin\"][\"Read\"][]> {\n const response = await this.sendAdminRequest(\"/internal/api-keys\", {}, null);\n const result = await response.json() as InternalApiKeysCrud[\"Admin\"][\"List\"];\n return result.items;\n }\n\n async revokeInternalApiKeyById(id: string) {\n await this.sendAdminRequest(\n `/internal/api-keys/${id}`, {\n method: \"PATCH\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({\n revoked: true,\n }),\n },\n null,\n );\n }\n\n async getInternalApiKey(id: string, session: InternalSession): Promise<InternalApiKeysCrud[\"Admin\"][\"Read\"]> {\n const response = await this.sendAdminRequest(`/internal/api-keys/${id}`, {}, session);\n return await response.json();\n }\n\n async listInternalEmailTemplates(): Promise<{ id: string, display_name: string, theme_id?: string, tsx_source: string }[]> {\n const response = await this.sendAdminRequest(`/internal/email-templates`, {}, null);\n const result = await response.json() as { templates: { id: string, display_name: string, theme_id?: string, tsx_source: string }[] };\n return result.templates;\n }\n\n async listEmailThemes(): Promise<{ id: string, display_name: string }[]> {\n const response = await this.sendAdminRequest(`/internal/email-themes`, {}, null);\n const result = await response.json() as { themes: { id: string, display_name: string }[] };\n return result.themes;\n }\n\n\n // Team permission definitions methods\n async listTeamPermissionDefinitions(): Promise<TeamPermissionDefinitionsCrud['Admin']['Read'][]> {\n const response = await this.sendAdminRequest(`/team-permission-definitions`, {}, null);\n const result = await response.json() as TeamPermissionDefinitionsCrud['Admin']['List'];\n return result.items;\n }\n\n async createTeamPermissionDefinition(data: TeamPermissionDefinitionsCrud['Admin']['Create']): Promise<TeamPermissionDefinitionsCrud['Admin']['Read']> {\n const response = await this.sendAdminRequest(\n \"/team-permission-definitions\",\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify(data),\n },\n null,\n );\n return await response.json();\n }\n\n async updateTeamPermissionDefinition(permissionId: string, data: TeamPermissionDefinitionsCrud['Admin']['Update']): Promise<TeamPermissionDefinitionsCrud['Admin']['Read']> {\n const response = await this.sendAdminRequest(\n `/team-permission-definitions/${permissionId}`,\n {\n method: \"PATCH\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify(data),\n },\n null,\n );\n return await response.json();\n }\n\n async deleteTeamPermissionDefinition(permissionId: string): Promise<void> {\n await this.sendAdminRequest(\n `/team-permission-definitions/${permissionId}`,\n { method: \"DELETE\" },\n null,\n );\n }\n\n async listProjectPermissionDefinitions(): Promise<ProjectPermissionDefinitionsCrud['Admin']['Read'][]> {\n const response = await this.sendAdminRequest(`/project-permission-definitions`, {}, null);\n const result = await response.json() as ProjectPermissionDefinitionsCrud['Admin']['List'];\n return result.items;\n }\n\n async createProjectPermissionDefinition(data: ProjectPermissionDefinitionsCrud['Admin']['Create']): Promise<ProjectPermissionDefinitionsCrud['Admin']['Read']> {\n const response = await this.sendAdminRequest(\n \"/project-permission-definitions\",\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify(data),\n },\n null,\n );\n return await response.json();\n }\n\n async updateProjectPermissionDefinition(permissionId: string, data: ProjectPermissionDefinitionsCrud['Admin']['Update']): Promise<ProjectPermissionDefinitionsCrud['Admin']['Read']> {\n const response = await this.sendAdminRequest(\n `/project-permission-definitions/${permissionId}`,\n {\n method: \"PATCH\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify(data),\n },\n null,\n );\n return await response.json();\n }\n\n async deleteProjectPermissionDefinition(permissionId: string): Promise<void> {\n await this.sendAdminRequest(\n `/project-permission-definitions/${permissionId}`,\n { method: \"DELETE\" },\n null,\n );\n }\n\n async getSvixToken(): Promise<SvixTokenCrud[\"Admin\"][\"Read\"]> {\n const response = await this.sendAdminRequest(\n \"/webhooks/svix-token\",\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({}),\n },\n null,\n );\n return await response.json();\n }\n\n async deleteProject(): Promise<void> {\n await this.sendAdminRequest(\n \"/internal/projects/current\",\n {\n method: \"DELETE\",\n },\n null,\n );\n }\n\n async getMetrics(): Promise<any> {\n const response = await this.sendAdminRequest(\n \"/internal/metrics\",\n {\n method: \"GET\",\n },\n null,\n );\n return await response.json();\n }\n\n async sendTestEmail(data: {\n recipient_email: string,\n email_config: {\n host: string,\n port: number,\n username: string,\n password: string,\n sender_email: string,\n sender_name: string,\n },\n }): Promise<{ success: boolean, error_message?: string }> {\n const response = await this.sendAdminRequest(`/internal/send-test-email`, {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify(data),\n }, null);\n return await response.json();\n }\n\n async listSentEmails(): Promise<InternalEmailsCrud[\"Admin\"][\"List\"]> {\n const response = await this.sendAdminRequest(\"/internal/emails\", {\n method: \"GET\",\n }, null);\n return await response.json();\n }\n\n async sendSignInInvitationEmail(\n email: string,\n callbackUrl: string,\n ): Promise<void> {\n await this.sendAdminRequest(\n \"/internal/send-sign-in-invitation\",\n {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\"\n },\n body: JSON.stringify({\n email,\n callback_url: callbackUrl,\n }),\n },\n null,\n );\n }\n\n\n async sendChatMessage(\n threadId: string,\n contextType: \"email-theme\" | \"email-template\",\n messages: Array<{ role: string, content: any }>,\n abortSignal?: AbortSignal,\n ): Promise<{ content: ChatContent }> {\n const response = await this.sendAdminRequest(\n `/internal/ai-chat/${threadId}`,\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({ context_type: contextType, messages }),\n signal: abortSignal,\n },\n null,\n );\n return await response.json();\n }\n\n async saveChatMessage(threadId: string, message: any): Promise<void> {\n await this.sendAdminRequest(\n `/internal/ai-chat/${threadId}`,\n {\n method: \"PATCH\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({ message }),\n },\n null,\n );\n }\n\n async listChatMessages(threadId: string): Promise<{ messages: Array<any> }> {\n const response = await this.sendAdminRequest(\n `/internal/ai-chat/${threadId}`,\n { method: \"GET\" },\n null,\n );\n return await response.json();\n }\n\n async renderEmailPreview(options: { themeId?: string | null | false, themeTsxSource?: string, templateId?: string, templateTsxSource?: string }): Promise<{ html: string }> {\n const response = await this.sendAdminRequest(`/emails/render-email`, {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({\n theme_id: options.themeId,\n theme_tsx_source: options.themeTsxSource,\n template_id: options.templateId,\n template_tsx_source: options.templateTsxSource,\n }),\n }, null);\n return await response.json();\n }\n\n async createEmailTheme(displayName: string): Promise<{ id: string }> {\n const response = await this.sendAdminRequest(\n `/internal/email-themes`,\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({\n display_name: displayName,\n }),\n },\n null,\n );\n return await response.json();\n }\n\n async getEmailTheme(id: string): Promise<{ display_name: string, tsx_source: string }> {\n const response = await this.sendAdminRequest(\n `/internal/email-themes/${id}`,\n { method: \"GET\" },\n null,\n );\n return await response.json();\n }\n\n async updateEmailTheme(id: string, tsxSource: string): Promise<void> {\n await this.sendAdminRequest(\n `/internal/email-themes/${id}`,\n {\n method: \"PATCH\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({\n tsx_source: tsxSource,\n }),\n },\n null,\n );\n }\n\n async updateEmailTemplate(id: string, tsxSource: string, themeId: string | null | false): Promise<{ rendered_html: string }> {\n const response = await this.sendAdminRequest(\n `/internal/email-templates/${id}`,\n {\n method: \"PATCH\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({ tsx_source: tsxSource, theme_id: themeId }),\n },\n null,\n );\n return await response.json();\n }\n\n async getConfig(): Promise<ConfigCrud[\"Admin\"][\"Read\"]> {\n const response = await this.sendAdminRequest(\n `/internal/config`,\n { method: \"GET\" },\n null,\n );\n return await response.json();\n }\n\n async updateConfig(data: { configOverride: any }): Promise<ConfigOverrideCrud[\"Admin\"][\"Read\"]> {\n const response = await this.sendAdminRequest(\n `/internal/config/override`,\n {\n method: \"PATCH\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({ config_override_string: JSON.stringify(data.configOverride) }),\n },\n null,\n );\n return await response.json();\n }\n async createEmailTemplate(displayName: string): Promise<{ id: string }> {\n const response = await this.sendAdminRequest(\n `/internal/email-templates`,\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({\n display_name: displayName,\n }),\n },\n null,\n );\n return await response.json();\n }\n\n async setupPayments(): Promise<{ url: string }> {\n const response = await this.sendAdminRequest(\n \"/internal/payments/setup\",\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({}),\n },\n null,\n );\n return await response.json();\n }\n\n async createStripeWidgetAccountSession(): Promise<{ client_secret: string }> {\n const response = await this.sendAdminRequest(\n \"/internal/payments/stripe-widgets/account-session\",\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({}),\n },\n null,\n );\n return await response.json();\n }\n\n async createPurchaseUrl(options: { customer_id: string, offer_id: string }): Promise<string> {\n const response = await this.sendAdminRequest(\n \"/payments/purchases/create-purchase-url\",\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify(options),\n },\n null,\n );\n const result = await response.json() as { url: string };\n return result.url;\n }\n\n async createItemQuantityChange(options: { customer_id: string, item_id: string, quantity: number, expires_at?: string, description?: string }): Promise<{ id: string }> {\n const response = await this.sendAdminRequest(\n `/payments/items/${options.customer_id}/${options.item_id}`,\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({\n quantity: options.quantity,\n expires_at: options.expires_at,\n description: options.description,\n }),\n },\n null,\n );\n const result = await response.json() as { id: string };\n return result;\n }\n\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,8BAAmE;AA8B5D,IAAM,sBAAN,cAAkC,6CAAqB;AAAA,EAC5D,YAA4B,SAAsC;AAChE,UAAM,OAAO;AADa;AAAA,EAE5B;AAAA,EAEA,MAAa,iBAAiB,MAAc,SAAsB,SAAiC,cAAuB,SAAS;AACjI,WAAO,MAAM,KAAK;AAAA,MAChB;AAAA,MACA;AAAA,QACE,GAAG;AAAA,QACH,SAAS;AAAA,UACP,kCAAkC,yBAAyB,KAAK,UAAU,KAAK,QAAQ,sBAAsB;AAAA,UAC7G,GAAG,QAAQ;AAAA,QACb;AAAA,MACF;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,aAAqD;AACzD,UAAM,WAAW,MAAM,KAAK;AAAA,MAC1B;AAAA,MACA;AAAA,QACE,QAAQ;AAAA,MACV;AAAA,MACA;AAAA,IACF;AACA,WAAO,MAAM,SAAS,KAAK;AAAA,EAC7B;AAAA,EAEA,MAAM,cAAc,QAAiF;AACnG,UAAM,WAAW,MAAM,KAAK;AAAA,MAC1B;AAAA,MACA;AAAA,QACE,QAAQ;AAAA,QACR,SAAS;AAAA,UACP,gBAAgB;AAAA,QAClB;AAAA,QACA,MAAM,KAAK,UAAU,MAAM;AAAA,MAC7B;AAAA,MACA;AAAA,IACF;AACA,WAAO,MAAM,SAAS,KAAK;AAAA,EAC7B;AAAA,EAEA,MAAM,qBACJ,SAC2C;AAC3C,UAAM,WAAW,MAAM,KAAK;AAAA,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MACA;AAAA,QACE,QAAQ;AAAA,QACR,SAAS;AAAA,UACP,gBAAgB;AAAA,QAClB;AAAA,QACA,MAAM,KAAK,UAAU,CAAC,CAAC;AAAA,MACzB;AAAA,MACA;AAAA,IACF;AACA,WAAO,MAAM,SAAS,KAAK;AAAA,EAC7B;AAAA,EAEA,MAAM,kBAAkB,SAAqE;AAC3F,UAAM,WAAW,MAAM,KAAK;AAAA,MAC1B;AAAA,MACA;AAAA,QACE,QAAQ;AAAA,QACR,SAAS;AAAA,UACP,gBAAgB;AAAA,QAClB;AAAA,QACA,MAAM,KAAK,UAAU,OAAO;AAAA,MAC9B;AAAA,MACA;AAAA,IACF;AACA,UAAM,SAAS,MAAM,SAAS,KAAK;AACnC,WAAO,OAAO;AAAA,EAChB;AAAA,EAEA,MAAM,yBAAyB,SAAyI;AACtK,UAAM,WAAW,MAAM,KAAK;AAAA,MAC1B,mBAAmB,QAAQ,WAAW,IAAI,QAAQ,OAAO;AAAA,MACzD;AAAA,QACE,QAAQ;AAAA,QACR,SAAS;AAAA,UACP,gBAAgB;AAAA,QAClB;AAAA,QACA,MAAM,KAAK,UAAU;AAAA,UACnB,UAAU,QAAQ;AAAA,UAClB,YAAY,QAAQ;AAAA,UACpB,aAAa,QAAQ;AAAA,QACvB,CAAC;AAAA,MACH;AAAA,MACA;AAAA,IACF;AACA,UAAM,SAAS,MAAM,SAAS,KAAK;AACnC,WAAO;AAAA,EACT;AAEF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/interface/admin-interface.ts"],"sourcesContent":["import { InternalSession } from \"../sessions\";\nimport { ConfigCrud, ConfigOverrideCrud } from \"./crud/config\";\nimport { InternalEmailsCrud } from \"./crud/emails\";\nimport { InternalApiKeysCrud } from \"./crud/internal-api-keys\";\nimport { ProjectPermissionDefinitionsCrud } from \"./crud/project-permissions\";\nimport { ProjectsCrud } from \"./crud/projects\";\nimport { SvixTokenCrud } from \"./crud/svix-token\";\nimport { TeamPermissionDefinitionsCrud } from \"./crud/team-permissions\";\nimport { ServerAuthApplicationOptions, StackServerInterface } from \"./server-interface\";\n\nexport type ChatContent = Array<\n | { type: \"text\", text: string }\n | { type: \"tool-call\", toolName: string, toolCallId: string, args: any, argsText: string, result: any }\n>;\n\nexport type AdminAuthApplicationOptions = ServerAuthApplicationOptions &(\n | {\n superSecretAdminKey: string,\n }\n | {\n projectOwnerSession: InternalSession,\n }\n);\n\nexport type InternalApiKeyCreateCrudRequest = {\n has_publishable_client_key: boolean,\n has_secret_server_key: boolean,\n has_super_secret_admin_key: boolean,\n expires_at_millis: number,\n description: string,\n};\n\nexport type InternalApiKeyCreateCrudResponse = InternalApiKeysCrud[\"Admin\"][\"Read\"] & {\n publishable_client_key?: string,\n secret_server_key?: string,\n super_secret_admin_key?: string,\n};\n\nexport class StackAdminInterface extends StackServerInterface {\n constructor(public readonly options: AdminAuthApplicationOptions) {\n super(options);\n }\n\n public async sendAdminRequest(path: string, options: RequestInit, session: InternalSession | null, requestType: \"admin\" = \"admin\") {\n return await this.sendServerRequest(\n path,\n {\n ...options,\n headers: {\n \"x-stack-super-secret-admin-key\": \"superSecretAdminKey\" in this.options ? this.options.superSecretAdminKey : \"\",\n ...options.headers,\n },\n },\n session,\n requestType,\n );\n }\n\n async getProject(): Promise<ProjectsCrud[\"Admin\"][\"Read\"]> {\n const response = await this.sendAdminRequest(\n \"/internal/projects/current\",\n {\n method: \"GET\",\n },\n null,\n );\n return await response.json();\n }\n\n async updateProject(update: ProjectsCrud[\"Admin\"][\"Update\"]): Promise<ProjectsCrud[\"Admin\"][\"Read\"]> {\n const response = await this.sendAdminRequest(\n \"/internal/projects/current\",\n {\n method: \"PATCH\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify(update),\n },\n null,\n );\n return await response.json();\n }\n\n async createInternalApiKey(\n options: InternalApiKeyCreateCrudRequest,\n ): Promise<InternalApiKeyCreateCrudResponse> {\n const response = await this.sendAdminRequest(\n \"/internal/api-keys\",\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify(options),\n },\n null,\n );\n return await response.json();\n }\n\n async listInternalApiKeys(): Promise<InternalApiKeysCrud[\"Admin\"][\"Read\"][]> {\n const response = await this.sendAdminRequest(\"/internal/api-keys\", {}, null);\n const result = await response.json() as InternalApiKeysCrud[\"Admin\"][\"List\"];\n return result.items;\n }\n\n async revokeInternalApiKeyById(id: string) {\n await this.sendAdminRequest(\n `/internal/api-keys/${id}`, {\n method: \"PATCH\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({\n revoked: true,\n }),\n },\n null,\n );\n }\n\n async getInternalApiKey(id: string, session: InternalSession): Promise<InternalApiKeysCrud[\"Admin\"][\"Read\"]> {\n const response = await this.sendAdminRequest(`/internal/api-keys/${id}`, {}, session);\n return await response.json();\n }\n\n async listInternalEmailTemplates(): Promise<{ id: string, display_name: string, theme_id?: string, tsx_source: string }[]> {\n const response = await this.sendAdminRequest(`/internal/email-templates`, {}, null);\n const result = await response.json() as { templates: { id: string, display_name: string, theme_id?: string, tsx_source: string }[] };\n return result.templates;\n }\n\n async listEmailThemes(): Promise<{ id: string, display_name: string }[]> {\n const response = await this.sendAdminRequest(`/internal/email-themes`, {}, null);\n const result = await response.json() as { themes: { id: string, display_name: string }[] };\n return result.themes;\n }\n\n\n // Team permission definitions methods\n async listTeamPermissionDefinitions(): Promise<TeamPermissionDefinitionsCrud['Admin']['Read'][]> {\n const response = await this.sendAdminRequest(`/team-permission-definitions`, {}, null);\n const result = await response.json() as TeamPermissionDefinitionsCrud['Admin']['List'];\n return result.items;\n }\n\n async createTeamPermissionDefinition(data: TeamPermissionDefinitionsCrud['Admin']['Create']): Promise<TeamPermissionDefinitionsCrud['Admin']['Read']> {\n const response = await this.sendAdminRequest(\n \"/team-permission-definitions\",\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify(data),\n },\n null,\n );\n return await response.json();\n }\n\n async updateTeamPermissionDefinition(permissionId: string, data: TeamPermissionDefinitionsCrud['Admin']['Update']): Promise<TeamPermissionDefinitionsCrud['Admin']['Read']> {\n const response = await this.sendAdminRequest(\n `/team-permission-definitions/${permissionId}`,\n {\n method: \"PATCH\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify(data),\n },\n null,\n );\n return await response.json();\n }\n\n async deleteTeamPermissionDefinition(permissionId: string): Promise<void> {\n await this.sendAdminRequest(\n `/team-permission-definitions/${permissionId}`,\n { method: \"DELETE\" },\n null,\n );\n }\n\n async listProjectPermissionDefinitions(): Promise<ProjectPermissionDefinitionsCrud['Admin']['Read'][]> {\n const response = await this.sendAdminRequest(`/project-permission-definitions`, {}, null);\n const result = await response.json() as ProjectPermissionDefinitionsCrud['Admin']['List'];\n return result.items;\n }\n\n async createProjectPermissionDefinition(data: ProjectPermissionDefinitionsCrud['Admin']['Create']): Promise<ProjectPermissionDefinitionsCrud['Admin']['Read']> {\n const response = await this.sendAdminRequest(\n \"/project-permission-definitions\",\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify(data),\n },\n null,\n );\n return await response.json();\n }\n\n async updateProjectPermissionDefinition(permissionId: string, data: ProjectPermissionDefinitionsCrud['Admin']['Update']): Promise<ProjectPermissionDefinitionsCrud['Admin']['Read']> {\n const response = await this.sendAdminRequest(\n `/project-permission-definitions/${permissionId}`,\n {\n method: \"PATCH\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify(data),\n },\n null,\n );\n return await response.json();\n }\n\n async deleteProjectPermissionDefinition(permissionId: string): Promise<void> {\n await this.sendAdminRequest(\n `/project-permission-definitions/${permissionId}`,\n { method: \"DELETE\" },\n null,\n );\n }\n\n async getSvixToken(): Promise<SvixTokenCrud[\"Admin\"][\"Read\"]> {\n const response = await this.sendAdminRequest(\n \"/webhooks/svix-token\",\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({}),\n },\n null,\n );\n return await response.json();\n }\n\n async deleteProject(): Promise<void> {\n await this.sendAdminRequest(\n \"/internal/projects/current\",\n {\n method: \"DELETE\",\n },\n null,\n );\n }\n\n async transferProject(session: InternalSession, newTeamId: string): Promise<void> {\n await this.sendAdminRequest(\n \"/internal/projects/transfer\",\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({\n project_id: this.options.projectId,\n new_team_id: newTeamId,\n }),\n },\n session,\n );\n }\n\n async getMetrics(): Promise<any> {\n const response = await this.sendAdminRequest(\n \"/internal/metrics\",\n {\n method: \"GET\",\n },\n null,\n );\n return await response.json();\n }\n\n async sendTestEmail(data: {\n recipient_email: string,\n email_config: {\n host: string,\n port: number,\n username: string,\n password: string,\n sender_email: string,\n sender_name: string,\n },\n }): Promise<{ success: boolean, error_message?: string }> {\n const response = await this.sendAdminRequest(`/internal/send-test-email`, {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify(data),\n }, null);\n return await response.json();\n }\n\n async listSentEmails(): Promise<InternalEmailsCrud[\"Admin\"][\"List\"]> {\n const response = await this.sendAdminRequest(\"/internal/emails\", {\n method: \"GET\",\n }, null);\n return await response.json();\n }\n\n async sendSignInInvitationEmail(\n email: string,\n callbackUrl: string,\n ): Promise<void> {\n await this.sendAdminRequest(\n \"/internal/send-sign-in-invitation\",\n {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\"\n },\n body: JSON.stringify({\n email,\n callback_url: callbackUrl,\n }),\n },\n null,\n );\n }\n\n\n async sendChatMessage(\n threadId: string,\n contextType: \"email-theme\" | \"email-template\",\n messages: Array<{ role: string, content: any }>,\n abortSignal?: AbortSignal,\n ): Promise<{ content: ChatContent }> {\n const response = await this.sendAdminRequest(\n `/internal/ai-chat/${threadId}`,\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({ context_type: contextType, messages }),\n signal: abortSignal,\n },\n null,\n );\n return await response.json();\n }\n\n async saveChatMessage(threadId: string, message: any): Promise<void> {\n await this.sendAdminRequest(\n `/internal/ai-chat/${threadId}`,\n {\n method: \"PATCH\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({ message }),\n },\n null,\n );\n }\n\n async listChatMessages(threadId: string): Promise<{ messages: Array<any> }> {\n const response = await this.sendAdminRequest(\n `/internal/ai-chat/${threadId}`,\n { method: \"GET\" },\n null,\n );\n return await response.json();\n }\n\n async renderEmailPreview(options: { themeId?: string | null | false, themeTsxSource?: string, templateId?: string, templateTsxSource?: string }): Promise<{ html: string }> {\n const response = await this.sendAdminRequest(`/emails/render-email`, {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({\n theme_id: options.themeId,\n theme_tsx_source: options.themeTsxSource,\n template_id: options.templateId,\n template_tsx_source: options.templateTsxSource,\n }),\n }, null);\n return await response.json();\n }\n\n async createEmailTheme(displayName: string): Promise<{ id: string }> {\n const response = await this.sendAdminRequest(\n `/internal/email-themes`,\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({\n display_name: displayName,\n }),\n },\n null,\n );\n return await response.json();\n }\n\n async getEmailTheme(id: string): Promise<{ display_name: string, tsx_source: string }> {\n const response = await this.sendAdminRequest(\n `/internal/email-themes/${id}`,\n { method: \"GET\" },\n null,\n );\n return await response.json();\n }\n\n async updateEmailTheme(id: string, tsxSource: string): Promise<void> {\n await this.sendAdminRequest(\n `/internal/email-themes/${id}`,\n {\n method: \"PATCH\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({\n tsx_source: tsxSource,\n }),\n },\n null,\n );\n }\n\n async updateEmailTemplate(id: string, tsxSource: string, themeId: string | null | false): Promise<{ rendered_html: string }> {\n const response = await this.sendAdminRequest(\n `/internal/email-templates/${id}`,\n {\n method: \"PATCH\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({ tsx_source: tsxSource, theme_id: themeId }),\n },\n null,\n );\n return await response.json();\n }\n\n async getConfig(): Promise<ConfigCrud[\"Admin\"][\"Read\"]> {\n const response = await this.sendAdminRequest(\n `/internal/config`,\n { method: \"GET\" },\n null,\n );\n return await response.json();\n }\n\n async updateConfig(data: { configOverride: any }): Promise<ConfigOverrideCrud[\"Admin\"][\"Read\"]> {\n const response = await this.sendAdminRequest(\n `/internal/config/override`,\n {\n method: \"PATCH\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({ config_override_string: JSON.stringify(data.configOverride) }),\n },\n null,\n );\n return await response.json();\n }\n async createEmailTemplate(displayName: string): Promise<{ id: string }> {\n const response = await this.sendAdminRequest(\n `/internal/email-templates`,\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({\n display_name: displayName,\n }),\n },\n null,\n );\n return await response.json();\n }\n\n async setupPayments(): Promise<{ url: string }> {\n const response = await this.sendAdminRequest(\n \"/internal/payments/setup\",\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({}),\n },\n null,\n );\n return await response.json();\n }\n\n async createStripeWidgetAccountSession(): Promise<{ client_secret: string }> {\n const response = await this.sendAdminRequest(\n \"/internal/payments/stripe-widgets/account-session\",\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({}),\n },\n null,\n );\n return await response.json();\n }\n\n async createPurchaseUrl(options: { customer_id: string, offer_id: string }): Promise<string> {\n const response = await this.sendAdminRequest(\n \"/payments/purchases/create-purchase-url\",\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify(options),\n },\n null,\n );\n const result = await response.json() as { url: string };\n return result.url;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,8BAAmE;AA8B5D,IAAM,sBAAN,cAAkC,6CAAqB;AAAA,EAC5D,YAA4B,SAAsC;AAChE,UAAM,OA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