@stackframe/stack-shared 2.8.34 → 2.8.36

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.
Files changed (110) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/config/schema.d.mts +249 -236
  3. package/dist/config/schema.d.ts +249 -236
  4. package/dist/config/schema.js +76 -54
  5. package/dist/config/schema.js.map +1 -1
  6. package/dist/esm/config/schema.js +76 -54
  7. package/dist/esm/config/schema.js.map +1 -1
  8. package/dist/esm/helpers/vault/client-side.js +46 -0
  9. package/dist/esm/helpers/vault/client-side.js.map +1 -0
  10. package/dist/esm/helpers/vault/server-side.js +92 -0
  11. package/dist/esm/helpers/vault/server-side.js.map +1 -0
  12. package/dist/esm/hooks/use-hover.js +71 -0
  13. package/dist/esm/hooks/use-hover.js.map +1 -0
  14. package/dist/esm/interface/admin-interface.js +30 -8
  15. package/dist/esm/interface/admin-interface.js.map +1 -1
  16. package/dist/esm/interface/client-interface.js +18 -4
  17. package/dist/esm/interface/client-interface.js.map +1 -1
  18. package/dist/esm/interface/server-interface.js +57 -10
  19. package/dist/esm/interface/server-interface.js.map +1 -1
  20. package/dist/esm/known-errors.js +38 -1
  21. package/dist/esm/known-errors.js.map +1 -1
  22. package/dist/esm/schema-fields.js +22 -9
  23. package/dist/esm/schema-fields.js.map +1 -1
  24. package/dist/esm/utils/bytes.js +1 -2
  25. package/dist/esm/utils/bytes.js.map +1 -1
  26. package/dist/esm/utils/crypto.js +83 -2
  27. package/dist/esm/utils/crypto.js.map +1 -1
  28. package/dist/esm/utils/currencies.js +0 -38
  29. package/dist/esm/utils/currencies.js.map +1 -1
  30. package/dist/esm/utils/currency-constants.js +42 -0
  31. package/dist/esm/utils/currency-constants.js.map +1 -0
  32. package/dist/esm/utils/dates.js +30 -0
  33. package/dist/esm/utils/dates.js.map +1 -1
  34. package/dist/esm/utils/numbers.js.map +1 -1
  35. package/dist/esm/utils/react.js +7 -3
  36. package/dist/esm/utils/react.js.map +1 -1
  37. package/dist/esm/utils/strings.js +3 -0
  38. package/dist/esm/utils/strings.js.map +1 -1
  39. package/dist/esm/utils/types.js.map +1 -1
  40. package/dist/helpers/password.d.mts +5 -5
  41. package/dist/helpers/password.d.ts +5 -5
  42. package/dist/helpers/vault/client-side.d.mts +14 -0
  43. package/dist/helpers/vault/client-side.d.ts +14 -0
  44. package/dist/helpers/vault/client-side.js +73 -0
  45. package/dist/helpers/vault/client-side.js.map +1 -0
  46. package/dist/helpers/vault/server-side.d.mts +7 -0
  47. package/dist/helpers/vault/server-side.d.ts +7 -0
  48. package/dist/helpers/vault/server-side.js +111 -0
  49. package/dist/helpers/vault/server-side.js.map +1 -0
  50. package/dist/hooks/use-hover.d.mts +6 -0
  51. package/dist/hooks/use-hover.d.ts +6 -0
  52. package/dist/hooks/use-hover.js +96 -0
  53. package/dist/hooks/use-hover.js.map +1 -0
  54. package/dist/index.d.mts +4 -4
  55. package/dist/index.d.ts +4 -4
  56. package/dist/interface/admin-interface.d.mts +22 -9
  57. package/dist/interface/admin-interface.d.ts +22 -9
  58. package/dist/interface/admin-interface.js +30 -8
  59. package/dist/interface/admin-interface.js.map +1 -1
  60. package/dist/interface/client-interface.d.mts +11 -6
  61. package/dist/interface/client-interface.d.ts +11 -6
  62. package/dist/interface/client-interface.js +18 -4
  63. package/dist/interface/client-interface.js.map +1 -1
  64. package/dist/interface/crud/current-user.d.mts +1 -1
  65. package/dist/interface/crud/current-user.d.ts +1 -1
  66. package/dist/interface/crud/project-api-keys.d.mts +2 -2
  67. package/dist/interface/crud/project-api-keys.d.ts +2 -2
  68. package/dist/interface/crud/team-member-profiles.d.mts +2 -2
  69. package/dist/interface/crud/team-member-profiles.d.ts +2 -2
  70. package/dist/interface/crud/users.d.mts +4 -4
  71. package/dist/interface/crud/users.d.ts +4 -4
  72. package/dist/interface/server-interface.d.mts +13 -2
  73. package/dist/interface/server-interface.d.ts +13 -2
  74. package/dist/interface/server-interface.js +57 -10
  75. package/dist/interface/server-interface.js.map +1 -1
  76. package/dist/known-errors.d.mts +12 -3
  77. package/dist/known-errors.d.ts +12 -3
  78. package/dist/known-errors.js +38 -1
  79. package/dist/known-errors.js.map +1 -1
  80. package/dist/schema-fields.d.mts +23 -7
  81. package/dist/schema-fields.d.ts +23 -7
  82. package/dist/schema-fields.js +25 -11
  83. package/dist/schema-fields.js.map +1 -1
  84. package/dist/utils/bytes.js +1 -2
  85. package/dist/utils/bytes.js.map +1 -1
  86. package/dist/utils/crypto.d.mts +31 -1
  87. package/dist/utils/crypto.d.ts +31 -1
  88. package/dist/utils/crypto.js +87 -2
  89. package/dist/utils/crypto.js.map +1 -1
  90. package/dist/utils/currencies.d.mts +3 -36
  91. package/dist/utils/currencies.d.ts +3 -36
  92. package/dist/utils/currencies.js +0 -39
  93. package/dist/utils/currencies.js.map +1 -1
  94. package/dist/utils/currency-constants.d.mts +37 -0
  95. package/dist/utils/currency-constants.d.ts +37 -0
  96. package/dist/utils/currency-constants.js +67 -0
  97. package/dist/utils/currency-constants.js.map +1 -0
  98. package/dist/utils/dates.d.mts +3 -1
  99. package/dist/utils/dates.d.ts +3 -1
  100. package/dist/utils/dates.js +32 -0
  101. package/dist/utils/dates.js.map +1 -1
  102. package/dist/utils/numbers.js.map +1 -1
  103. package/dist/utils/react.js +7 -3
  104. package/dist/utils/react.js.map +1 -1
  105. package/dist/utils/strings.js +3 -0
  106. package/dist/utils/strings.js.map +1 -1
  107. package/dist/utils/types.d.mts +5 -4
  108. package/dist/utils/types.d.ts +5 -4
  109. package/dist/utils/types.js.map +1 -1
  110. package/package.json +2 -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 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":[]}
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\ntype primitive = string | number | boolean | bigint | symbol | null | undefined;\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 ? ((...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 : T extends object\n ? T extends primitive\n ? T\n : T extends infer O\n ? { [K in keyof O]: Expand<O[K]> }\n : never\n : T;\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":";AAkDA,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":[]}
@@ -1,13 +1,13 @@
1
- import '../crud.mjs';
2
1
  import { KnownErrors } from '../known-errors.mjs';
2
+ import '../crud.mjs';
3
3
  import '../schema-fields.mjs';
4
- import 'yup';
5
- import '../utils/types.mjs';
6
- import '../utils/strings.mjs';
7
4
  import '../utils/errors.mjs';
8
5
  import '../utils/json.mjs';
9
6
  import '../utils/results.mjs';
10
- import '../utils/currencies.mjs';
7
+ import 'yup';
8
+ import '../utils/types.mjs';
9
+ import '../utils/strings.mjs';
10
+ import '../utils/currency-constants.mjs';
11
11
  import '../utils/dates.mjs';
12
12
 
13
13
  declare function getPasswordError(password: string): KnownErrors["PasswordRequirementsNotMet"] | undefined;
@@ -1,13 +1,13 @@
1
- import '../crud.js';
2
1
  import { KnownErrors } from '../known-errors.js';
2
+ import '../crud.js';
3
3
  import '../schema-fields.js';
4
- import 'yup';
5
- import '../utils/types.js';
6
- import '../utils/strings.js';
7
4
  import '../utils/errors.js';
8
5
  import '../utils/json.js';
9
6
  import '../utils/results.js';
10
- import '../utils/currencies.js';
7
+ import 'yup';
8
+ import '../utils/types.js';
9
+ import '../utils/strings.js';
10
+ import '../utils/currency-constants.js';
11
11
  import '../utils/dates.js';
12
12
 
13
13
  declare function getPasswordError(password: string): KnownErrors["PasswordRequirementsNotMet"] | undefined;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Use to hash the key so the server cannot infer it.
3
+ */
4
+ declare function hashKey(secret: string, key: string): Promise<string>;
5
+ /**
6
+ * Use to encrypt the value so that the server cannot read the value without knowing the key.
7
+ */
8
+ declare function encryptValue(secret: string, key: string, value: string): Promise<string>;
9
+ /**
10
+ * Use to decrypt the value. See encryptValue.
11
+ */
12
+ declare function decryptValue(secret: string, key: string, encryptedValue: string): Promise<string>;
13
+
14
+ export { decryptValue, encryptValue, hashKey };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Use to hash the key so the server cannot infer it.
3
+ */
4
+ declare function hashKey(secret: string, key: string): Promise<string>;
5
+ /**
6
+ * Use to encrypt the value so that the server cannot read the value without knowing the key.
7
+ */
8
+ declare function encryptValue(secret: string, key: string, value: string): Promise<string>;
9
+ /**
10
+ * Use to decrypt the value. See encryptValue.
11
+ */
12
+ declare function decryptValue(secret: string, key: string, encryptedValue: string): Promise<string>;
13
+
14
+ export { decryptValue, encryptValue, hashKey };
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/helpers/vault/client-side.ts
21
+ var client_side_exports = {};
22
+ __export(client_side_exports, {
23
+ decryptValue: () => decryptValue,
24
+ encryptValue: () => encryptValue,
25
+ hashKey: () => hashKey
26
+ });
27
+ module.exports = __toCommonJS(client_side_exports);
28
+ var import_bytes = require("../../utils/bytes.js");
29
+ var import_crypto = require("../../utils/crypto.js");
30
+ var hashPurpose = "stack-data-vault-client-side-encryption-key-hash";
31
+ var encryptionSecretPurpose = "stack-data-vault-client-side-encryption-value-encryption-key-hash";
32
+ var encryptionValuePurpose = "stack-data-vault-client-side-encryption-value-encryption-value-encryption";
33
+ async function getDerivedKey(secret, key) {
34
+ return await (0, import_crypto.iteratedHash)({
35
+ purpose: encryptionSecretPurpose,
36
+ extra: secret,
37
+ value: key,
38
+ iterations: 1e5
39
+ });
40
+ }
41
+ async function hashKey(secret, key) {
42
+ return (0, import_bytes.encodeBase64)(await (0, import_crypto.hash)({
43
+ purpose: hashPurpose,
44
+ extra: secret,
45
+ value: await getDerivedKey(secret, key)
46
+ }));
47
+ }
48
+ async function encryptValue(secret, key, value) {
49
+ const valueEncryptionDerivedKey = await getDerivedKey(secret, key);
50
+ const bytes = await (0, import_crypto.encrypt)({
51
+ purpose: encryptionValuePurpose,
52
+ secret: valueEncryptionDerivedKey,
53
+ value: new TextEncoder().encode(value)
54
+ });
55
+ return (0, import_bytes.encodeBase64)(bytes);
56
+ }
57
+ async function decryptValue(secret, key, encryptedValue) {
58
+ const valueEncryptionDerivedKey = await getDerivedKey(secret, key);
59
+ const bytesResult = await (0, import_crypto.decrypt)({
60
+ purpose: encryptionValuePurpose,
61
+ secret: valueEncryptionDerivedKey,
62
+ cipher: (0, import_bytes.decodeBase64)(encryptedValue)
63
+ });
64
+ if (bytesResult.status === "error") throw new Error("Data vault client-side decryption failed. Are you sure you're using the correct secret?", { cause: bytesResult.error });
65
+ return new TextDecoder().decode(bytesResult.data);
66
+ }
67
+ // Annotate the CommonJS export names for ESM import in node:
68
+ 0 && (module.exports = {
69
+ decryptValue,
70
+ encryptValue,
71
+ hashKey
72
+ });
73
+ //# sourceMappingURL=client-side.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/helpers/vault/client-side.ts"],"sourcesContent":["import { decodeBase64, encodeBase64 } from \"../../utils/bytes\";\nimport { decrypt, encrypt, hash, iteratedHash } from \"../../utils/crypto\";\n\nconst hashPurpose = \"stack-data-vault-client-side-encryption-key-hash\";\nconst encryptionSecretPurpose = \"stack-data-vault-client-side-encryption-value-encryption-key-hash\";\nconst encryptionValuePurpose = \"stack-data-vault-client-side-encryption-value-encryption-value-encryption\";\n\n\nasync function getDerivedKey(secret: string, key: string) {\n return await iteratedHash({\n purpose: encryptionSecretPurpose,\n extra: secret,\n value: key,\n iterations: 100_000,\n });\n}\n\n/**\n * Use to hash the key so the server cannot infer it.\n */\nexport async function hashKey(secret: string, key: string) {\n return encodeBase64(await hash({\n purpose: hashPurpose,\n extra: secret,\n value: await getDerivedKey(secret, key),\n }));\n}\n\n/**\n * Use to encrypt the value so that the server cannot read the value without knowing the key.\n */\nexport async function encryptValue(secret: string, key: string, value: string) {\n const valueEncryptionDerivedKey = await getDerivedKey(secret, key);\n\n const bytes = await encrypt({\n purpose: encryptionValuePurpose,\n secret: valueEncryptionDerivedKey,\n value: new TextEncoder().encode(value)\n });\n return encodeBase64(bytes);\n}\n\n/**\n * Use to decrypt the value. See encryptValue.\n */\nexport async function decryptValue(secret: string, key: string, encryptedValue: string) {\n const valueEncryptionDerivedKey = await getDerivedKey(secret, key);\n\n const bytesResult = await decrypt({\n purpose: encryptionValuePurpose,\n secret: valueEncryptionDerivedKey,\n cipher: decodeBase64(encryptedValue),\n });\n if (bytesResult.status === \"error\") throw new Error(\"Data vault client-side decryption failed. Are you sure you're using the correct secret?\", { cause: bytesResult.error });\n return new TextDecoder().decode(bytesResult.data);\n}\n\n\nundefined?.describe(\"encryptValue & decryptValue\", () => {\n undefined?.it(\"should encrypt and decrypt a value\", async ({ expect }) => {\n const secret = \"test-secret\";\n const value = \"test-value\";\n const encrypted = await encryptValue(secret, \"key\", value);\n const decrypted = await decryptValue(secret, \"key\", encrypted);\n expect(decrypted).toEqual(value);\n });\n\n undefined?.it(\"should not decrypt a value with a different secret\", async ({ expect }) => {\n const secret = \"test-secret\";\n const value = \"test-value\";\n const encrypted = await encryptValue(secret, \"key\", value);\n await expect(decryptValue(\"different-secret\", \"key\", encrypted)).rejects.toThrow();\n });\n\n undefined?.it(\"should not decrypt a value with a different key\", async ({ expect }) => {\n const secret = \"test-secret\";\n const value = \"test-value\";\n const encrypted = await encryptValue(secret, \"key\", value);\n await expect(decryptValue(secret, \"different-key\", encrypted)).rejects.toThrow();\n });\n\n undefined?.it(\"should not decrypt a value if the cipher was tampered with\", async ({ expect }) => {\n const secret = \"test-secret\";\n const value = \"test-value\";\n const encrypted = await encryptValue(secret, \"key\", value);\n const tampered = encrypted + \"7\";\n await expect(decryptValue(secret, \"key\", tampered)).rejects.toThrow();\n });\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA2C;AAC3C,oBAAqD;AAErD,IAAM,cAAc;AACpB,IAAM,0BAA0B;AAChC,IAAM,yBAAyB;AAG/B,eAAe,cAAc,QAAgB,KAAa;AACxD,SAAO,UAAM,4BAAa;AAAA,IACxB,SAAS;AAAA,IACT,OAAO;AAAA,IACP,OAAO;AAAA,IACP,YAAY;AAAA,EACd,CAAC;AACH;AAKA,eAAsB,QAAQ,QAAgB,KAAa;AACzD,aAAO,2BAAa,UAAM,oBAAK;AAAA,IAC7B,SAAS;AAAA,IACT,OAAO;AAAA,IACP,OAAO,MAAM,cAAc,QAAQ,GAAG;AAAA,EACxC,CAAC,CAAC;AACJ;AAKA,eAAsB,aAAa,QAAgB,KAAa,OAAe;AAC7E,QAAM,4BAA4B,MAAM,cAAc,QAAQ,GAAG;AAEjE,QAAM,QAAQ,UAAM,uBAAQ;AAAA,IAC1B,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,OAAO,IAAI,YAAY,EAAE,OAAO,KAAK;AAAA,EACvC,CAAC;AACD,aAAO,2BAAa,KAAK;AAC3B;AAKA,eAAsB,aAAa,QAAgB,KAAa,gBAAwB;AACtF,QAAM,4BAA4B,MAAM,cAAc,QAAQ,GAAG;AAEjE,QAAM,cAAc,UAAM,uBAAQ;AAAA,IAChC,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,YAAQ,2BAAa,cAAc;AAAA,EACrC,CAAC;AACD,MAAI,YAAY,WAAW,QAAS,OAAM,IAAI,MAAM,2FAA2F,EAAE,OAAO,YAAY,MAAM,CAAC;AAC3K,SAAO,IAAI,YAAY,EAAE,OAAO,YAAY,IAAI;AAClD;","names":[]}
@@ -0,0 +1,7 @@
1
+ declare function encryptWithKms(value: string): Promise<{
2
+ edkBase64: string;
3
+ ciphertextBase64: string;
4
+ }>;
5
+ declare function decryptWithKms(encrypted: Awaited<ReturnType<typeof encryptWithKms>>): Promise<string>;
6
+
7
+ export { decryptWithKms, encryptWithKms };
@@ -0,0 +1,7 @@
1
+ declare function encryptWithKms(value: string): Promise<{
2
+ edkBase64: string;
3
+ ciphertextBase64: string;
4
+ }>;
5
+ declare function decryptWithKms(encrypted: Awaited<ReturnType<typeof encryptWithKms>>): Promise<string>;
6
+
7
+ export { decryptWithKms, encryptWithKms };
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/helpers/vault/server-side.ts
21
+ var server_side_exports = {};
22
+ __export(server_side_exports, {
23
+ decryptWithKms: () => decryptWithKms,
24
+ encryptWithKms: () => encryptWithKms
25
+ });
26
+ module.exports = __toCommonJS(server_side_exports);
27
+ var import_client_kms = require("@aws-sdk/client-kms");
28
+ var import_bytes = require("../../utils/bytes.js");
29
+ var import_crypto = require("../../utils/crypto.js");
30
+ var import_env = require("../../utils/env.js");
31
+ var import_results = require("../../utils/results.js");
32
+ function getKmsClient() {
33
+ return new import_client_kms.KMSClient({
34
+ region: (0, import_env.getEnvVariable)("STACK_AWS_REGION"),
35
+ endpoint: (0, import_env.getEnvVariable)("STACK_AWS_KMS_ENDPOINT"),
36
+ credentials: {
37
+ accessKeyId: (0, import_env.getEnvVariable)("STACK_AWS_ACCESS_KEY_ID"),
38
+ secretAccessKey: (0, import_env.getEnvVariable)("STACK_AWS_SECRET_ACCESS_KEY")
39
+ }
40
+ });
41
+ }
42
+ async function getOrCreateKekId() {
43
+ const id = "alias/stack-data-vault-server-side-kek";
44
+ const kms = getKmsClient();
45
+ try {
46
+ const describeResult = await kms.send(new import_client_kms.DescribeKeyCommand({ KeyId: id }));
47
+ if (describeResult.KeyMetadata?.KeyId) return describeResult.KeyMetadata.KeyId;
48
+ } catch (e) {
49
+ if (e instanceof Error && e.name !== "NotFoundException") {
50
+ throw e;
51
+ }
52
+ }
53
+ const { KeyMetadata } = await kms.send(new import_client_kms.CreateKeyCommand({
54
+ KeyUsage: "ENCRYPT_DECRYPT",
55
+ Description: "DataVault KEK"
56
+ }));
57
+ await kms.send(new import_client_kms.CreateAliasCommand({ AliasName: id, TargetKeyId: KeyMetadata.KeyId }));
58
+ return id;
59
+ }
60
+ async function genDEK() {
61
+ const kekId = await getOrCreateKekId();
62
+ const kms = getKmsClient();
63
+ const out = await kms.send(new import_client_kms.GenerateDataKeyCommand({ KeyId: kekId, KeySpec: "AES_256" }));
64
+ if (!out.Plaintext || !out.CiphertextBlob) throw new Error("GenerateDataKey failed");
65
+ return {
66
+ dekBytes: out.Plaintext,
67
+ edkBytes: out.CiphertextBlob
68
+ };
69
+ }
70
+ async function unwrapDEK(edk_b64) {
71
+ const edkBytes = (0, import_bytes.decodeBase64)(edk_b64);
72
+ const kms = getKmsClient();
73
+ const out = await kms.send(new import_client_kms.DecryptCommand({ CiphertextBlob: edkBytes }));
74
+ if (!out.Plaintext) throw new Error("KMS Decrypt failed");
75
+ return {
76
+ dekBytes: out.Plaintext,
77
+ edkBytes
78
+ };
79
+ }
80
+ async function encryptWithKms(value) {
81
+ const { dekBytes, edkBytes } = await genDEK();
82
+ try {
83
+ const ciphertext = await (0, import_crypto.encrypt)({
84
+ purpose: "stack-data-vault-server-side-encryption",
85
+ secret: dekBytes,
86
+ value: new TextEncoder().encode(value)
87
+ });
88
+ return { edkBase64: (0, import_bytes.encodeBase64)(edkBytes), ciphertextBase64: (0, import_bytes.encodeBase64)(ciphertext) };
89
+ } finally {
90
+ dekBytes.fill(0);
91
+ }
92
+ }
93
+ async function decryptWithKms(encrypted) {
94
+ const { dekBytes } = await unwrapDEK(encrypted.edkBase64);
95
+ try {
96
+ const value = import_results.Result.orThrow(await (0, import_crypto.decrypt)({
97
+ purpose: "stack-data-vault-server-side-encryption",
98
+ secret: dekBytes,
99
+ cipher: (0, import_bytes.decodeBase64)(encrypted.ciphertextBase64)
100
+ }));
101
+ return new TextDecoder().decode(value);
102
+ } finally {
103
+ dekBytes.fill(0);
104
+ }
105
+ }
106
+ // Annotate the CommonJS export names for ESM import in node:
107
+ 0 && (module.exports = {
108
+ decryptWithKms,
109
+ encryptWithKms
110
+ });
111
+ //# sourceMappingURL=server-side.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/helpers/vault/server-side.ts"],"sourcesContent":["import {\n CreateAliasCommand,\n CreateKeyCommand,\n DecryptCommand,\n DescribeKeyCommand,\n GenerateDataKeyCommand,\n KMSClient\n} from \"@aws-sdk/client-kms\";\nimport { decodeBase64, encodeBase64 } from \"../../utils/bytes\";\nimport { decrypt, encrypt } from \"../../utils/crypto\";\nimport { getEnvVariable } from \"../../utils/env\";\nimport { Result } from \"../../utils/results\";\n\nfunction getKmsClient() {\n return new KMSClient({\n region: getEnvVariable(\"STACK_AWS_REGION\"),\n endpoint: getEnvVariable(\"STACK_AWS_KMS_ENDPOINT\"),\n credentials: {\n accessKeyId: getEnvVariable(\"STACK_AWS_ACCESS_KEY_ID\"),\n secretAccessKey: getEnvVariable(\"STACK_AWS_SECRET_ACCESS_KEY\")\n }\n });\n}\n\nasync function getOrCreateKekId(): Promise<string> {\n const id = \"alias/stack-data-vault-server-side-kek\";\n const kms = getKmsClient();\n try {\n const describeResult = await kms.send(new DescribeKeyCommand({ KeyId: id }));\n if (describeResult.KeyMetadata?.KeyId) return describeResult.KeyMetadata.KeyId;\n } catch (e) {\n if (e instanceof Error && e.name !== \"NotFoundException\") {\n throw e;\n }\n }\n const { KeyMetadata } = await kms.send(new CreateKeyCommand({\n KeyUsage: \"ENCRYPT_DECRYPT\",\n Description: \"DataVault KEK\"\n }));\n await kms.send(new CreateAliasCommand({ AliasName: id, TargetKeyId: KeyMetadata!.KeyId! }));\n return id;\n}\n\nasync function genDEK() {\n const kekId = await getOrCreateKekId();\n const kms = getKmsClient();\n const out = await kms.send(new GenerateDataKeyCommand({ KeyId: kekId, KeySpec: \"AES_256\" }));\n if (!out.Plaintext || !out.CiphertextBlob) throw new Error(\"GenerateDataKey failed\");\n return {\n dekBytes: out.Plaintext,\n edkBytes: out.CiphertextBlob,\n };\n}\n\nasync function unwrapDEK(edk_b64: string) {\n const edkBytes = decodeBase64(edk_b64);\n const kms = getKmsClient();\n const out = await kms.send(new DecryptCommand({ CiphertextBlob: edkBytes }));\n if (!out.Plaintext) throw new Error(\"KMS Decrypt failed\");\n return {\n dekBytes: out.Plaintext,\n edkBytes,\n };\n}\n\nexport async function encryptWithKms(value: string) {\n const { dekBytes, edkBytes } = await genDEK();\n try {\n const ciphertext = await encrypt({\n purpose: \"stack-data-vault-server-side-encryption\",\n secret: dekBytes,\n value: new TextEncoder().encode(value),\n });\n return { edkBase64: encodeBase64(edkBytes), ciphertextBase64: encodeBase64(ciphertext) };\n } finally {\n dekBytes.fill(0);\n }\n}\n\nexport async function decryptWithKms(encrypted: Awaited<ReturnType<typeof encryptWithKms>>) {\n const { dekBytes } = await unwrapDEK(encrypted.edkBase64);\n try {\n const value = Result.orThrow(await decrypt({\n purpose: \"stack-data-vault-server-side-encryption\",\n secret: dekBytes,\n cipher: decodeBase64(encrypted.ciphertextBase64),\n }));\n return new TextDecoder().decode(value);\n } finally {\n dekBytes.fill(0);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAOO;AACP,mBAA2C;AAC3C,oBAAiC;AACjC,iBAA+B;AAC/B,qBAAuB;AAEvB,SAAS,eAAe;AACtB,SAAO,IAAI,4BAAU;AAAA,IACnB,YAAQ,2BAAe,kBAAkB;AAAA,IACzC,cAAU,2BAAe,wBAAwB;AAAA,IACjD,aAAa;AAAA,MACX,iBAAa,2BAAe,yBAAyB;AAAA,MACrD,qBAAiB,2BAAe,6BAA6B;AAAA,IAC/D;AAAA,EACF,CAAC;AACH;AAEA,eAAe,mBAAoC;AACjD,QAAM,KAAK;AACX,QAAM,MAAM,aAAa;AACzB,MAAI;AACF,UAAM,iBAAiB,MAAM,IAAI,KAAK,IAAI,qCAAmB,EAAE,OAAO,GAAG,CAAC,CAAC;AAC3E,QAAI,eAAe,aAAa,MAAO,QAAO,eAAe,YAAY;AAAA,EAC3E,SAAS,GAAG;AACV,QAAI,aAAa,SAAS,EAAE,SAAS,qBAAqB;AACxD,YAAM;AAAA,IACR;AAAA,EACF;AACA,QAAM,EAAE,YAAY,IAAI,MAAM,IAAI,KAAK,IAAI,mCAAiB;AAAA,IAC1D,UAAU;AAAA,IACV,aAAa;AAAA,EACf,CAAC,CAAC;AACF,QAAM,IAAI,KAAK,IAAI,qCAAmB,EAAE,WAAW,IAAI,aAAa,YAAa,MAAO,CAAC,CAAC;AAC1F,SAAO;AACT;AAEA,eAAe,SAAS;AACtB,QAAM,QAAQ,MAAM,iBAAiB;AACrC,QAAM,MAAM,aAAa;AACzB,QAAM,MAAM,MAAM,IAAI,KAAK,IAAI,yCAAuB,EAAE,OAAO,OAAO,SAAS,UAAU,CAAC,CAAC;AAC3F,MAAI,CAAC,IAAI,aAAa,CAAC,IAAI,eAAgB,OAAM,IAAI,MAAM,wBAAwB;AACnF,SAAO;AAAA,IACL,UAAU,IAAI;AAAA,IACd,UAAU,IAAI;AAAA,EAChB;AACF;AAEA,eAAe,UAAU,SAAiB;AACxC,QAAM,eAAW,2BAAa,OAAO;AACrC,QAAM,MAAM,aAAa;AACzB,QAAM,MAAM,MAAM,IAAI,KAAK,IAAI,iCAAe,EAAE,gBAAgB,SAAS,CAAC,CAAC;AAC3E,MAAI,CAAC,IAAI,UAAW,OAAM,IAAI,MAAM,oBAAoB;AACxD,SAAO;AAAA,IACL,UAAU,IAAI;AAAA,IACd;AAAA,EACF;AACF;AAEA,eAAsB,eAAe,OAAe;AAClD,QAAM,EAAE,UAAU,SAAS,IAAI,MAAM,OAAO;AAC5C,MAAI;AACF,UAAM,aAAa,UAAM,uBAAQ;AAAA,MAC/B,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,OAAO,IAAI,YAAY,EAAE,OAAO,KAAK;AAAA,IACvC,CAAC;AACD,WAAO,EAAE,eAAW,2BAAa,QAAQ,GAAG,sBAAkB,2BAAa,UAAU,EAAE;AAAA,EACzF,UAAE;AACA,aAAS,KAAK,CAAC;AAAA,EACjB;AACF;AAEA,eAAsB,eAAe,WAAuD;AAC1F,QAAM,EAAE,SAAS,IAAI,MAAM,UAAU,UAAU,SAAS;AACxD,MAAI;AACF,UAAM,QAAQ,sBAAO,QAAQ,UAAM,uBAAQ;AAAA,MACzC,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,YAAQ,2BAAa,UAAU,gBAAgB;AAAA,IACjD,CAAC,CAAC;AACF,WAAO,IAAI,YAAY,EAAE,OAAO,KAAK;AAAA,EACvC,UAAE;AACA,aAAS,KAAK,CAAC;AAAA,EACjB;AACF;","names":[]}
@@ -0,0 +1,6 @@
1
+ declare function useHover<T extends HTMLElement>(ref: React.RefObject<T>, options?: {
2
+ onMouseEnter?: () => void;
3
+ onMouseLeave?: () => void;
4
+ }): boolean;
5
+
6
+ export { useHover };
@@ -0,0 +1,6 @@
1
+ declare function useHover<T extends HTMLElement>(ref: React.RefObject<T>, options?: {
2
+ onMouseEnter?: () => void;
3
+ onMouseLeave?: () => void;
4
+ }): boolean;
5
+
6
+ export { useHover };
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/hooks/use-hover.tsx
21
+ var use_hover_exports = {};
22
+ __export(use_hover_exports, {
23
+ useHover: () => useHover
24
+ });
25
+ module.exports = __toCommonJS(use_hover_exports);
26
+ var import_react = require("react");
27
+ var import_react2 = require("../utils/react.js");
28
+ function useHover(ref, options = {}) {
29
+ const counter = (0, import_react2.useRefState)(0);
30
+ (0, import_react.useLayoutEffect)(() => {
31
+ const el = ref.current;
32
+ if (!el) return;
33
+ let incr = 0;
34
+ let prevInside = false;
35
+ const contains = (r, x, y) => x >= r.left && x <= r.right && y >= r.top && y <= r.bottom;
36
+ const enter = () => {
37
+ incr++;
38
+ counter.set((c) => c + 1);
39
+ if (counter.current === 1) {
40
+ options.onMouseEnter?.();
41
+ }
42
+ };
43
+ const leave = () => {
44
+ incr--;
45
+ requestAnimationFrame(() => {
46
+ requestAnimationFrame(() => {
47
+ counter.set((c) => c - 1);
48
+ if (counter.current === 0) {
49
+ options.onMouseLeave?.();
50
+ }
51
+ });
52
+ });
53
+ };
54
+ const topMatchesTarget = (x, y) => {
55
+ const top = document.elementFromPoint(x, y);
56
+ return !!(top && (top === el || el.contains(top)));
57
+ };
58
+ const processPoint = (x, y) => {
59
+ const rect = el.getBoundingClientRect();
60
+ const inside = contains(rect, x, y) && topMatchesTarget(x, y);
61
+ if (inside && !prevInside) {
62
+ enter();
63
+ } else if (!inside && prevInside) {
64
+ leave();
65
+ }
66
+ prevInside = inside;
67
+ };
68
+ const onMove = (e) => {
69
+ if (e.pointerType !== "mouse") return;
70
+ const batch = e.getCoalescedEvents();
71
+ if (batch.length) {
72
+ for (let eventIndex = 0; eventIndex < batch.length - 1; eventIndex++) {
73
+ const e1 = batch[eventIndex];
74
+ const e2 = batch[eventIndex + 1];
75
+ const steps = 10;
76
+ for (let i = 0; i <= steps; i++) {
77
+ processPoint(e1.clientX + (e2.clientX - e1.clientX) * i / steps, e1.clientY + (e2.clientY - e1.clientY) * i / steps);
78
+ }
79
+ }
80
+ } else {
81
+ processPoint(e.clientX, e.clientY);
82
+ }
83
+ };
84
+ window.addEventListener("pointermove", onMove, { passive: true });
85
+ return () => {
86
+ window.removeEventListener("pointermove", onMove);
87
+ counter.set((c) => c - incr);
88
+ };
89
+ }, []);
90
+ return counter.current > 0;
91
+ }
92
+ // Annotate the CommonJS export names for ESM import in node:
93
+ 0 && (module.exports = {
94
+ useHover
95
+ });
96
+ //# sourceMappingURL=use-hover.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/hooks/use-hover.tsx"],"sourcesContent":["import { useLayoutEffect } from \"react\";\nimport { useRefState } from \"../utils/react\";\n\nexport function useHover<T extends HTMLElement>(\n ref: React.RefObject<T>,\n options: {\n onMouseEnter?: () => void,\n onMouseLeave?: () => void,\n } = {},\n): boolean {\n // Internal counter: mouseenter++ / mouseleave-- (isHovering = counter > 0)\n const counter = useRefState(0);\n\n useLayoutEffect(() => {\n const el = ref.current;\n if (!el) return;\n let incr = 0;\n let prevInside = false;\n\n const contains = (r: DOMRect, x: number, y: number) =>\n x >= r.left && x <= r.right && y >= r.top && y <= r.bottom;\n\n const enter = () => {\n incr++;\n counter.set(c => c + 1);\n if (counter.current === 1) {\n options.onMouseEnter?.();\n }\n };\n\n const leave = () => {\n incr--;\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n counter.set(c => c - 1);\n if (counter.current === 0) {\n options.onMouseLeave?.();\n }\n });\n });\n };\n\n const topMatchesTarget = (x: number, y: number) => {\n const top = document.elementFromPoint(x, y);\n return !!(top && (top === el || el.contains(top)));\n };\n\n const processPoint = (x: number, y: number) => {\n const rect = el.getBoundingClientRect();\n\n // True “hoverability”: inside rect AND not occluded by others\n const inside = contains(rect, x, y) && topMatchesTarget(x, y);\n if (inside && !prevInside) {\n enter();\n } else if (!inside && prevInside) {\n leave();\n }\n prevInside = inside;\n };\n\n const onMove = (e: PointerEvent) => {\n if (e.pointerType !== \"mouse\") return; // keep it hover-only\n // Use coalesced points when available\n const batch = e.getCoalescedEvents();\n if (batch.length) {\n for (let eventIndex = 0; eventIndex < batch.length - 1; eventIndex++) {\n const e1 = batch[eventIndex];\n const e2 = batch[eventIndex + 1];\n const steps = 10;\n for (let i = 0; i <= steps; i++) {\n processPoint(e1.clientX + (e2.clientX - e1.clientX) * i / steps, e1.clientY + (e2.clientY - e1.clientY) * i / steps);\n }\n }\n } else {\n processPoint(e.clientX, e.clientY);\n }\n };\n\n window.addEventListener(\"pointermove\", onMove, { passive: true });\n\n return () => {\n window.removeEventListener(\"pointermove\", onMove);\n counter.set(c => c - incr);\n };\n }, []);\n\n return counter.current > 0;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAgC;AAChC,IAAAA,gBAA4B;AAErB,SAAS,SACd,KACA,UAGI,CAAC,GACI;AAET,QAAM,cAAU,2BAAY,CAAC;AAE7B,oCAAgB,MAAM;AACpB,UAAM,KAAK,IAAI;AACf,QAAI,CAAC,GAAI;AACT,QAAI,OAAO;AACX,QAAI,aAAa;AAEjB,UAAM,WAAW,CAAC,GAAY,GAAW,MACvC,KAAK,EAAE,QAAQ,KAAK,EAAE,SAAS,KAAK,EAAE,OAAO,KAAK,EAAE;AAEtD,UAAM,QAAQ,MAAM;AAClB;AACA,cAAQ,IAAI,OAAK,IAAI,CAAC;AACtB,UAAI,QAAQ,YAAY,GAAG;AACzB,gBAAQ,eAAe;AAAA,MACzB;AAAA,IACF;AAEA,UAAM,QAAQ,MAAM;AAClB;AACA,4BAAsB,MAAM;AAC1B,8BAAsB,MAAM;AAC1B,kBAAQ,IAAI,OAAK,IAAI,CAAC;AACtB,cAAI,QAAQ,YAAY,GAAG;AACzB,oBAAQ,eAAe;AAAA,UACzB;AAAA,QACF,CAAC;AAAA,MACH,CAAC;AAAA,IACH;AAEA,UAAM,mBAAmB,CAAC,GAAW,MAAc;AACjD,YAAM,MAAM,SAAS,iBAAiB,GAAG,CAAC;AAC1C,aAAO,CAAC,EAAE,QAAQ,QAAQ,MAAM,GAAG,SAAS,GAAG;AAAA,IACjD;AAEA,UAAM,eAAe,CAAC,GAAW,MAAc;AAC7C,YAAM,OAAO,GAAG,sBAAsB;AAGtC,YAAM,SAAS,SAAS,MAAM,GAAG,CAAC,KAAK,iBAAiB,GAAG,CAAC;AAC5D,UAAI,UAAU,CAAC,YAAY;AACzB,cAAM;AAAA,MACR,WAAW,CAAC,UAAU,YAAY;AAChC,cAAM;AAAA,MACR;AACA,mBAAa;AAAA,IACf;AAEA,UAAM,SAAS,CAAC,MAAoB;AAClC,UAAI,EAAE,gBAAgB,QAAS;AAE/B,YAAM,QAAQ,EAAE,mBAAmB;AACnC,UAAI,MAAM,QAAQ;AAChB,iBAAS,aAAa,GAAG,aAAa,MAAM,SAAS,GAAG,cAAc;AACpE,gBAAM,KAAK,MAAM,UAAU;AAC3B,gBAAM,KAAK,MAAM,aAAa,CAAC;AAC/B,gBAAM,QAAQ;AACd,mBAAS,IAAI,GAAG,KAAK,OAAO,KAAK;AAC/B,yBAAa,GAAG,WAAW,GAAG,UAAU,GAAG,WAAW,IAAI,OAAO,GAAG,WAAW,GAAG,UAAU,GAAG,WAAW,IAAI,KAAK;AAAA,UACrH;AAAA,QACF;AAAA,MACF,OAAO;AACL,qBAAa,EAAE,SAAS,EAAE,OAAO;AAAA,MACnC;AAAA,IACF;AAEA,WAAO,iBAAiB,eAAe,QAAQ,EAAE,SAAS,KAAK,CAAC;AAEhE,WAAO,MAAM;AACX,aAAO,oBAAoB,eAAe,MAAM;AAChD,cAAQ,IAAI,OAAK,IAAI,IAAI;AAAA,IAC3B;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO,QAAQ,UAAU;AAC3B;","names":["import_react"]}
package/dist/index.d.mts CHANGED
@@ -4,6 +4,7 @@ export { StackServerInterface } from './interface/server-interface.mjs';
4
4
  export { KnownError, KnownErrors } from './known-errors.mjs';
5
5
  import './sessions.mjs';
6
6
  import 'jose';
7
+ import './utils/results.mjs';
7
8
  import './interface/crud/config.mjs';
8
9
  import './crud.mjs';
9
10
  import 'yup';
@@ -15,7 +16,8 @@ import './interface/crud/project-permissions.mjs';
15
16
  import './interface/crud/projects.mjs';
16
17
  import './interface/crud/svix-token.mjs';
17
18
  import './interface/crud/team-permissions.mjs';
18
- import './utils/results.mjs';
19
+ import './utils/errors.mjs';
20
+ import './utils/json.mjs';
19
21
  import './interface/crud/connected-accounts.mjs';
20
22
  import './interface/crud/contact-channels.mjs';
21
23
  import './interface/crud/current-user.mjs';
@@ -27,10 +29,8 @@ import './interface/crud/team-member-profiles.mjs';
27
29
  import './interface/crud/team-memberships.mjs';
28
30
  import './interface/crud/teams.mjs';
29
31
  import './interface/crud/users.mjs';
30
- import './utils/errors.mjs';
31
- import './utils/json.mjs';
32
32
  import './schema-fields.mjs';
33
- import './utils/currencies.mjs';
33
+ import './utils/currency-constants.mjs';
34
34
  import './utils/dates.mjs';
35
35
  import '@simplewebauthn/types';
36
36
  import './interface/crud/project-api-keys.mjs';
package/dist/index.d.ts CHANGED
@@ -4,6 +4,7 @@ export { StackServerInterface } from './interface/server-interface.js';
4
4
  export { KnownError, KnownErrors } from './known-errors.js';
5
5
  import './sessions.js';
6
6
  import 'jose';
7
+ import './utils/results.js';
7
8
  import './interface/crud/config.js';
8
9
  import './crud.js';
9
10
  import 'yup';
@@ -15,7 +16,8 @@ import './interface/crud/project-permissions.js';
15
16
  import './interface/crud/projects.js';
16
17
  import './interface/crud/svix-token.js';
17
18
  import './interface/crud/team-permissions.js';
18
- import './utils/results.js';
19
+ import './utils/errors.js';
20
+ import './utils/json.js';
19
21
  import './interface/crud/connected-accounts.js';
20
22
  import './interface/crud/contact-channels.js';
21
23
  import './interface/crud/current-user.js';
@@ -27,10 +29,8 @@ import './interface/crud/team-member-profiles.js';
27
29
  import './interface/crud/team-memberships.js';
28
30
  import './interface/crud/teams.js';
29
31
  import './interface/crud/users.js';
30
- import './utils/errors.js';
31
- import './utils/json.js';
32
32
  import './schema-fields.js';
33
- import './utils/currencies.js';
33
+ import './utils/currency-constants.js';
34
34
  import './utils/dates.js';
35
35
  import '@simplewebauthn/types';
36
36
  import './interface/crud/project-api-keys.js';
@@ -1,4 +1,6 @@
1
+ import { KnownErrors } from '../known-errors.mjs';
1
2
  import { InternalSession, AccessToken, RefreshToken } from '../sessions.mjs';
3
+ import { Result } from '../utils/results.mjs';
2
4
  import { ConfigCrud, ConfigOverrideCrud } from './crud/config.mjs';
3
5
  import { InternalEmailsCrud } from './crud/emails.mjs';
4
6
  import { InternalApiKeysCrud } from './crud/internal-api-keys.mjs';
@@ -8,13 +10,13 @@ import { SvixTokenCrud } from './crud/svix-token.mjs';
8
10
  import { TeamPermissionDefinitionsCrud } from './crud/team-permissions.mjs';
9
11
  import { ServerAuthApplicationOptions, StackServerInterface } from './server-interface.mjs';
10
12
  import './client-interface.mjs';
11
- import '../known-errors.mjs';
13
+ import '../utils/errors.mjs';
14
+ import '../utils/json.mjs';
12
15
  import 'jose';
13
16
  import '../crud.mjs';
14
17
  import 'yup';
15
18
  import '../utils/types.mjs';
16
19
  import '../utils/strings.mjs';
17
- import '../utils/results.mjs';
18
20
  import './crud/connected-accounts.mjs';
19
21
  import './crud/contact-channels.mjs';
20
22
  import './crud/current-user.mjs';
@@ -26,10 +28,8 @@ import './crud/team-member-profiles.mjs';
26
28
  import './crud/team-memberships.mjs';
27
29
  import './crud/teams.mjs';
28
30
  import './crud/users.mjs';
29
- import '../utils/errors.mjs';
30
- import '../utils/json.mjs';
31
31
  import '../schema-fields.mjs';
32
- import '../utils/currencies.mjs';
32
+ import '../utils/currency-constants.mjs';
33
33
  import '../utils/dates.mjs';
34
34
  import '@simplewebauthn/types';
35
35
  import './crud/project-api-keys.mjs';
@@ -71,6 +71,12 @@ declare class StackAdminInterface extends StackServerInterface {
71
71
  refreshToken: RefreshToken | null;
72
72
  } | null;
73
73
  }>;
74
+ protected sendAdminRequestAndCatchKnownError<E extends typeof KnownErrors[keyof KnownErrors]>(path: string, requestOptions: RequestInit, tokenStoreOrNull: InternalSession | null, errorsToCatch: readonly E[]): Promise<Result<Response & {
75
+ usedTokens: {
76
+ accessToken: AccessToken;
77
+ refreshToken: RefreshToken | null;
78
+ } | null;
79
+ }, InstanceType<E>>>;
74
80
  getProject(): Promise<ProjectsCrud["Admin"]["Read"]>;
75
81
  updateProject(update: ProjectsCrud["Admin"]["Update"]): Promise<ProjectsCrud["Admin"]["Read"]>;
76
82
  createInternalApiKey(options: InternalApiKeyCreateCrudRequest): Promise<InternalApiKeyCreateCrudResponse>;
@@ -154,13 +160,20 @@ declare class StackAdminInterface extends StackServerInterface {
154
160
  setupPayments(): Promise<{
155
161
  url: string;
156
162
  }>;
163
+ getStripeAccountInfo(): Promise<null | {
164
+ account_id: string;
165
+ charges_enabled: boolean;
166
+ details_submitted: boolean;
167
+ payouts_enabled: boolean;
168
+ }>;
157
169
  createStripeWidgetAccountSession(): Promise<{
158
170
  client_secret: string;
159
171
  }>;
160
- createPurchaseUrl(options: {
161
- customer_id: string;
162
- offer_id: string;
163
- }): Promise<string>;
172
+ testModePurchase(options: {
173
+ price_id: string;
174
+ full_code: string;
175
+ quantity?: number;
176
+ }): Promise<void>;
164
177
  }
165
178
 
166
179
  export { type AdminAuthApplicationOptions, type ChatContent, type InternalApiKeyCreateCrudRequest, type InternalApiKeyCreateCrudResponse, StackAdminInterface };