@vllnt/convex-push 0.0.0-stage → 0.1.0-canary.4a1ca91

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 (152) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/LICENSE +21 -0
  3. package/README.md +415 -2
  4. package/dist/client/index.d.ts +180 -0
  5. package/dist/client/index.d.ts.map +1 -0
  6. package/dist/client/index.js +152 -0
  7. package/dist/client/index.js.map +1 -0
  8. package/dist/component/_generated/api.d.ts +80 -0
  9. package/dist/component/_generated/api.d.ts.map +1 -0
  10. package/dist/component/_generated/api.js +31 -0
  11. package/dist/component/_generated/api.js.map +1 -0
  12. package/dist/component/_generated/component.d.ts +274 -0
  13. package/dist/component/_generated/component.d.ts.map +1 -0
  14. package/dist/component/_generated/component.js +11 -0
  15. package/dist/component/_generated/component.js.map +1 -0
  16. package/dist/component/_generated/dataModel.d.ts +46 -0
  17. package/dist/component/_generated/dataModel.d.ts.map +1 -0
  18. package/dist/component/_generated/dataModel.js +11 -0
  19. package/dist/component/_generated/dataModel.js.map +1 -0
  20. package/dist/component/_generated/server.d.ts +142 -0
  21. package/dist/component/_generated/server.d.ts.map +1 -0
  22. package/dist/component/_generated/server.js +80 -0
  23. package/dist/component/_generated/server.js.map +1 -0
  24. package/dist/component/actions.d.ts +29 -0
  25. package/dist/component/actions.d.ts.map +1 -0
  26. package/dist/component/actions.js +29 -0
  27. package/dist/component/actions.js.map +1 -0
  28. package/dist/component/checks.d.ts +27 -0
  29. package/dist/component/checks.d.ts.map +1 -0
  30. package/dist/component/checks.js +107 -0
  31. package/dist/component/checks.js.map +1 -0
  32. package/dist/component/convex.config.d.ts +18 -0
  33. package/dist/component/convex.config.d.ts.map +1 -0
  34. package/dist/component/convex.config.js +30 -0
  35. package/dist/component/convex.config.js.map +1 -0
  36. package/dist/component/crons.d.ts +8 -0
  37. package/dist/component/crons.d.ts.map +1 -0
  38. package/dist/component/crons.js +15 -0
  39. package/dist/component/crons.js.map +1 -0
  40. package/dist/component/crypto/codec.d.ts +64 -0
  41. package/dist/component/crypto/codec.d.ts.map +1 -0
  42. package/dist/component/crypto/codec.js +102 -0
  43. package/dist/component/crypto/codec.js.map +1 -0
  44. package/dist/component/crypto/jwt.d.ts +46 -0
  45. package/dist/component/crypto/jwt.d.ts.map +1 -0
  46. package/dist/component/crypto/jwt.js +82 -0
  47. package/dist/component/crypto/jwt.js.map +1 -0
  48. package/dist/component/crypto/token_seal.d.ts +31 -0
  49. package/dist/component/crypto/token_seal.d.ts.map +1 -0
  50. package/dist/component/crypto/token_seal.js +44 -0
  51. package/dist/component/crypto/token_seal.js.map +1 -0
  52. package/dist/component/crypto/web_push_crypto.d.ts +42 -0
  53. package/dist/component/crypto/web_push_crypto.d.ts.map +1 -0
  54. package/dist/component/crypto/web_push_crypto.js +49 -0
  55. package/dist/component/crypto/web_push_crypto.js.map +1 -0
  56. package/dist/component/internal_mutations.d.ts +48 -0
  57. package/dist/component/internal_mutations.d.ts.map +1 -0
  58. package/dist/component/internal_mutations.js +82 -0
  59. package/dist/component/internal_mutations.js.map +1 -0
  60. package/dist/component/mutations.d.ts +223 -0
  61. package/dist/component/mutations.d.ts.map +1 -0
  62. package/dist/component/mutations.js +244 -0
  63. package/dist/component/mutations.js.map +1 -0
  64. package/dist/component/providers/apns.d.ts +46 -0
  65. package/dist/component/providers/apns.d.ts.map +1 -0
  66. package/dist/component/providers/apns.js +105 -0
  67. package/dist/component/providers/apns.js.map +1 -0
  68. package/dist/component/providers/fcm.d.ts +36 -0
  69. package/dist/component/providers/fcm.d.ts.map +1 -0
  70. package/dist/component/providers/fcm.js +116 -0
  71. package/dist/component/providers/fcm.js.map +1 -0
  72. package/dist/component/providers/http.d.ts +45 -0
  73. package/dist/component/providers/http.d.ts.map +1 -0
  74. package/dist/component/providers/http.js +74 -0
  75. package/dist/component/providers/http.js.map +1 -0
  76. package/dist/component/providers/keys.d.ts +70 -0
  77. package/dist/component/providers/keys.d.ts.map +1 -0
  78. package/dist/component/providers/keys.js +89 -0
  79. package/dist/component/providers/keys.js.map +1 -0
  80. package/dist/component/providers/payload.d.ts +83 -0
  81. package/dist/component/providers/payload.d.ts.map +1 -0
  82. package/dist/component/providers/payload.js +162 -0
  83. package/dist/component/providers/payload.js.map +1 -0
  84. package/dist/component/providers/token_cache.d.ts +56 -0
  85. package/dist/component/providers/token_cache.d.ts.map +1 -0
  86. package/dist/component/providers/token_cache.js +42 -0
  87. package/dist/component/providers/token_cache.js.map +1 -0
  88. package/dist/component/providers/web_push.d.ts +40 -0
  89. package/dist/component/providers/web_push.d.ts.map +1 -0
  90. package/dist/component/providers/web_push.js +94 -0
  91. package/dist/component/providers/web_push.js.map +1 -0
  92. package/dist/component/queries.d.ts +132 -0
  93. package/dist/component/queries.d.ts.map +1 -0
  94. package/dist/component/queries.js +156 -0
  95. package/dist/component/queries.js.map +1 -0
  96. package/dist/component/queue.d.ts +66 -0
  97. package/dist/component/queue.d.ts.map +1 -0
  98. package/dist/component/queue.js +356 -0
  99. package/dist/component/queue.js.map +1 -0
  100. package/dist/component/registry.d.ts +46 -0
  101. package/dist/component/registry.d.ts.map +1 -0
  102. package/dist/component/registry.js +128 -0
  103. package/dist/component/registry.js.map +1 -0
  104. package/dist/component/schema.d.ts +286 -0
  105. package/dist/component/schema.d.ts.map +1 -0
  106. package/dist/component/schema.js +70 -0
  107. package/dist/component/schema.js.map +1 -0
  108. package/dist/component/senders.d.ts +67 -0
  109. package/dist/component/senders.d.ts.map +1 -0
  110. package/dist/component/senders.js +123 -0
  111. package/dist/component/senders.js.map +1 -0
  112. package/dist/component/validators.d.ts +784 -0
  113. package/dist/component/validators.d.ts.map +1 -0
  114. package/dist/component/validators.js +193 -0
  115. package/dist/component/validators.js.map +1 -0
  116. package/dist/shared.d.ts +109 -0
  117. package/dist/shared.d.ts.map +1 -0
  118. package/dist/shared.js +131 -0
  119. package/dist/shared.js.map +1 -0
  120. package/docs/API.md +258 -0
  121. package/llms.txt +33 -0
  122. package/package.json +125 -4
  123. package/src/client/index.ts +276 -0
  124. package/src/component/_generated/api.ts +96 -0
  125. package/src/component/_generated/component.ts +263 -0
  126. package/src/component/_generated/dataModel.ts +60 -0
  127. package/src/component/_generated/server.ts +178 -0
  128. package/src/component/actions.ts +31 -0
  129. package/src/component/checks.ts +117 -0
  130. package/src/component/convex.config.ts +32 -0
  131. package/src/component/crons.ts +17 -0
  132. package/src/component/crypto/codec.ts +113 -0
  133. package/src/component/crypto/jwt.ts +109 -0
  134. package/src/component/crypto/token_seal.ts +56 -0
  135. package/src/component/crypto/web_push_crypto.ts +75 -0
  136. package/src/component/internal_mutations.ts +88 -0
  137. package/src/component/mutations.ts +257 -0
  138. package/src/component/providers/apns.ts +116 -0
  139. package/src/component/providers/fcm.ts +132 -0
  140. package/src/component/providers/http.ts +78 -0
  141. package/src/component/providers/keys.ts +133 -0
  142. package/src/component/providers/payload.ts +200 -0
  143. package/src/component/providers/token_cache.ts +75 -0
  144. package/src/component/providers/web_push.ts +101 -0
  145. package/src/component/queries.ts +182 -0
  146. package/src/component/queue.ts +425 -0
  147. package/src/component/registry.ts +144 -0
  148. package/src/component/schema.ts +82 -0
  149. package/src/component/senders.ts +152 -0
  150. package/src/component/validators.ts +285 -0
  151. package/src/shared.ts +155 -0
  152. package/src/test.ts +25 -0
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Generated utilities for implementing server-side Convex query and mutation functions.
3
+ *
4
+ * THIS CODE IS AUTOMATICALLY GENERATED.
5
+ *
6
+ * To regenerate, run `npx convex dev`.
7
+ * @module
8
+ */
9
+ import type { ActionBuilder, HttpActionBuilder, MutationBuilder, QueryBuilder, GenericActionCtx, GenericMutationCtx, GenericQueryCtx, GenericDatabaseReader, GenericDatabaseWriter } from "convex/server";
10
+ import type { DataModel } from "./dataModel.js";
11
+ /**
12
+ * Typesafe environment variables.
13
+ *
14
+ * This includes platform-provided env vars and any variables declared in
15
+ * `convex.config.ts`.
16
+ */
17
+ type Env = {
18
+ readonly CONVEX_CLOUD_URL: string;
19
+ readonly CONVEX_SITE_URL: string;
20
+ readonly APNS_KEY_ID: string | undefined;
21
+ readonly APNS_KEY_P8: string | undefined;
22
+ readonly APNS_SANDBOX_KEY_ID: string | undefined;
23
+ readonly APNS_SANDBOX_KEY_P8: string | undefined;
24
+ readonly APNS_TEAM_ID: string | undefined;
25
+ readonly FCM_SERVICE_ACCOUNT_JSON: string | undefined;
26
+ readonly VAPID_PRIVATE_KEY: string | undefined;
27
+ readonly VAPID_PUBLIC_KEY: string | undefined;
28
+ readonly VAPID_SUBJECT: string | undefined;
29
+ };
30
+ /**
31
+ * Define a query in this Convex app's public API.
32
+ *
33
+ * This function will be allowed to read your Convex database and will be accessible from the client.
34
+ *
35
+ * @param func - The query function. It receives a {@link QueryCtx} as its first argument.
36
+ * @returns The wrapped query. Include this as an `export` to name it and make it accessible.
37
+ */
38
+ export declare const query: QueryBuilder<DataModel, "public">;
39
+ /**
40
+ * Define a query that is only accessible from other Convex functions (but not from the client).
41
+ *
42
+ * This function will be allowed to read from your Convex database. It will not be accessible from the client.
43
+ *
44
+ * @param func - The query function. It receives a {@link QueryCtx} as its first argument.
45
+ * @returns The wrapped query. Include this as an `export` to name it and make it accessible.
46
+ */
47
+ export declare const internalQuery: QueryBuilder<DataModel, "internal">;
48
+ /**
49
+ * Define a mutation in this Convex app's public API.
50
+ *
51
+ * This function will be allowed to modify your Convex database and will be accessible from the client.
52
+ *
53
+ * @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
54
+ * @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
55
+ */
56
+ export declare const mutation: MutationBuilder<DataModel, "public">;
57
+ /**
58
+ * Define a mutation that is only accessible from other Convex functions (but not from the client).
59
+ *
60
+ * This function will be allowed to modify your Convex database. It will not be accessible from the client.
61
+ *
62
+ * @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
63
+ * @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
64
+ */
65
+ export declare const internalMutation: MutationBuilder<DataModel, "internal">;
66
+ /**
67
+ * Define an action in this Convex app's public API.
68
+ *
69
+ * An action is a function which can execute any JavaScript code, including non-deterministic
70
+ * code and code with side-effects, like calling third-party services.
71
+ * They can be run in Convex's JavaScript environment or in Node.js using the "use node" directive.
72
+ * They can interact with the database indirectly by calling queries and mutations using the {@link ActionCtx}.
73
+ *
74
+ * @param func - The action. It receives an {@link ActionCtx} as its first argument.
75
+ * @returns The wrapped action. Include this as an `export` to name it and make it accessible.
76
+ */
77
+ export declare const action: ActionBuilder<DataModel, "public">;
78
+ /**
79
+ * Define an action that is only accessible from other Convex functions (but not from the client).
80
+ *
81
+ * @param func - The function. It receives an {@link ActionCtx} as its first argument.
82
+ * @returns The wrapped function. Include this as an `export` to name it and make it accessible.
83
+ */
84
+ export declare const internalAction: ActionBuilder<DataModel, "internal">;
85
+ /**
86
+ * Define an HTTP action.
87
+ *
88
+ * The wrapped function will be used to respond to HTTP requests received
89
+ * by a Convex deployment if the requests matches the path and method where
90
+ * this action is routed. Be sure to route your httpAction in `convex/http.js`.
91
+ *
92
+ * @param func - The function. It receives an {@link ActionCtx} as its first argument
93
+ * and a Fetch API `Request` object as its second.
94
+ * @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up.
95
+ */
96
+ export declare const httpAction: HttpActionBuilder;
97
+ export declare const env: Env;
98
+ /**
99
+ * A set of services for use within Convex query functions.
100
+ *
101
+ * The query context is passed as the first argument to any Convex query
102
+ * function run on the server.
103
+ *
104
+ * If you're using code generation, use the `QueryCtx` type in `convex/_generated/server.d.ts` instead.
105
+ */
106
+ export type QueryCtx = GenericQueryCtx<DataModel>;
107
+ /**
108
+ * A set of services for use within Convex mutation functions.
109
+ *
110
+ * The mutation context is passed as the first argument to any Convex mutation
111
+ * function run on the server.
112
+ *
113
+ * If you're using code generation, use the `MutationCtx` type in `convex/_generated/server.d.ts` instead.
114
+ */
115
+ export type MutationCtx = GenericMutationCtx<DataModel>;
116
+ /**
117
+ * A set of services for use within Convex action functions.
118
+ *
119
+ * The action context is passed as the first argument to any Convex action
120
+ * function run on the server.
121
+ */
122
+ export type ActionCtx = GenericActionCtx<DataModel>;
123
+ /**
124
+ * An interface to read from the database within Convex query functions.
125
+ *
126
+ * The two entry points are {@link DatabaseReader.get}, which fetches a single
127
+ * document by its {@link Id}, or {@link DatabaseReader.query}, which starts
128
+ * building a query.
129
+ */
130
+ export type DatabaseReader = GenericDatabaseReader<DataModel>;
131
+ /**
132
+ * An interface to read from and write to the database within Convex mutation
133
+ * functions.
134
+ *
135
+ * Convex guarantees that all writes within a single mutation are
136
+ * executed atomically, so you never have to worry about partial writes leaving
137
+ * your data in an inconsistent state. See [the Convex Guide](https://docs.convex.dev/understanding/convex-fundamentals/functions#atomicity-and-optimistic-concurrency-control)
138
+ * for the guarantees Convex provides your functions.
139
+ */
140
+ export type DatabaseWriter = GenericDatabaseWriter<DataModel>;
141
+ export {};
142
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/component/_generated/server.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,eAAe,CAAC;AAUvB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD;;;;;GAKG;AACH,KAAK,GAAG,GAAG;IACT,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,QAAQ,CAAC,mBAAmB,EAAE,MAAM,GAAG,SAAS,CAAC;IACjD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gB,CAAC,SAAS,CAAC,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG,qBAAqB,CAAC,SAAS,CAAC,CAAC;AAE9D;;;;;;;;GAQG;AACH,MAAM,MAAM,cAAc,GAAG,qBAAqB,CAAC,SAAS,CAAC,CAAC"}
@@ -0,0 +1,80 @@
1
+ /* eslint-disable */
2
+ /**
3
+ * Generated utilities for implementing server-side Convex query and mutation functions.
4
+ *
5
+ * THIS CODE IS AUTOMATICALLY GENERATED.
6
+ *
7
+ * To regenerate, run `npx convex dev`.
8
+ * @module
9
+ */
10
+ import { actionGeneric, httpActionGeneric, queryGeneric, mutationGeneric, internalActionGeneric, internalMutationGeneric, internalQueryGeneric, } from "convex/server";
11
+ /**
12
+ * Define a query in this Convex app's public API.
13
+ *
14
+ * This function will be allowed to read your Convex database and will be accessible from the client.
15
+ *
16
+ * @param func - The query function. It receives a {@link QueryCtx} as its first argument.
17
+ * @returns The wrapped query. Include this as an `export` to name it and make it accessible.
18
+ */
19
+ export const query = queryGeneric;
20
+ /**
21
+ * Define a query that is only accessible from other Convex functions (but not from the client).
22
+ *
23
+ * This function will be allowed to read from your Convex database. It will not be accessible from the client.
24
+ *
25
+ * @param func - The query function. It receives a {@link QueryCtx} as its first argument.
26
+ * @returns The wrapped query. Include this as an `export` to name it and make it accessible.
27
+ */
28
+ export const internalQuery = internalQueryGeneric;
29
+ /**
30
+ * Define a mutation in this Convex app's public API.
31
+ *
32
+ * This function will be allowed to modify your Convex database and will be accessible from the client.
33
+ *
34
+ * @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
35
+ * @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
36
+ */
37
+ export const mutation = mutationGeneric;
38
+ /**
39
+ * Define a mutation that is only accessible from other Convex functions (but not from the client).
40
+ *
41
+ * This function will be allowed to modify your Convex database. It will not be accessible from the client.
42
+ *
43
+ * @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
44
+ * @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
45
+ */
46
+ export const internalMutation = internalMutationGeneric;
47
+ /**
48
+ * Define an action in this Convex app's public API.
49
+ *
50
+ * An action is a function which can execute any JavaScript code, including non-deterministic
51
+ * code and code with side-effects, like calling third-party services.
52
+ * They can be run in Convex's JavaScript environment or in Node.js using the "use node" directive.
53
+ * They can interact with the database indirectly by calling queries and mutations using the {@link ActionCtx}.
54
+ *
55
+ * @param func - The action. It receives an {@link ActionCtx} as its first argument.
56
+ * @returns The wrapped action. Include this as an `export` to name it and make it accessible.
57
+ */
58
+ export const action = actionGeneric;
59
+ /**
60
+ * Define an action that is only accessible from other Convex functions (but not from the client).
61
+ *
62
+ * @param func - The function. It receives an {@link ActionCtx} as its first argument.
63
+ * @returns The wrapped function. Include this as an `export` to name it and make it accessible.
64
+ */
65
+ export const internalAction = internalActionGeneric;
66
+ /**
67
+ * Define an HTTP action.
68
+ *
69
+ * The wrapped function will be used to respond to HTTP requests received
70
+ * by a Convex deployment if the requests matches the path and method where
71
+ * this action is routed. Be sure to route your httpAction in `convex/http.js`.
72
+ *
73
+ * @param func - The function. It receives an {@link ActionCtx} as its first argument
74
+ * and a Fetch API `Request` object as its second.
75
+ * @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up.
76
+ */
77
+ export const httpAction = httpActionGeneric;
78
+ export const env = globalThis
79
+ .process.env;
80
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/component/_generated/server.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB;;;;;;;GAOG;AAaH,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,qBAAqB,EACrB,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,eAAe,CAAC;AAuBvB;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,KAAK,GAAsC,YAAY,CAAC;AAErE;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,aAAa,GACxB,oBAAoB,CAAC;AAEvB;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAyC,eAAe,CAAC;AAE9E;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAC3B,uBAAuB,CAAC;AAE1B;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,MAAM,GAAuC,aAAa,CAAC;AAExE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GACzB,qBAAqB,CAAC;AAExB;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,UAAU,GAAsB,iBAAiB,CAAC;AAC/D,MAAM,CAAC,MAAM,GAAG,GAAS,UAAmD;KACzE,OAAO,CAAC,GAAG,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Send one queued delivery. Runs in the default runtime (components cannot use
3
+ * Node actions): signing, encryption and HTTP/2 to Apple all use Web APIs.
4
+ * Returns `skip` when the delivery is no longer queued.
5
+ */
6
+ export declare const deliver: import("convex/server").RegisteredAction<"internal", {
7
+ deliveryId: import("convex/values").GenericId<"deliveries">;
8
+ }, Promise<{
9
+ httpStatus?: number | undefined;
10
+ providerMessageId?: string | undefined;
11
+ status: "sent";
12
+ } | {
13
+ code?: string | undefined;
14
+ delayMs?: number | undefined;
15
+ httpStatus?: number | undefined;
16
+ status: "retry";
17
+ } | {
18
+ code?: string | undefined;
19
+ httpStatus?: number | undefined;
20
+ invalidSince?: number | undefined;
21
+ status: "invalid";
22
+ } | {
23
+ code?: string | undefined;
24
+ httpStatus?: number | undefined;
25
+ status: "failed";
26
+ } | {
27
+ status: "skip";
28
+ }>>;
29
+ //# sourceMappingURL=actions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/component/actions.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;GAkBlB,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { v } from "convex/values";
2
+ import { internal } from "./_generated/api.js";
3
+ import { env, internalAction } from "./_generated/server.js";
4
+ import { createTokenCache } from "./providers/token_cache.js";
5
+ import { actionDeps, runSender } from "./senders.js";
6
+ import { deliverOutcome } from "./validators.js";
7
+ /**
8
+ * Send one queued delivery. Runs in the default runtime (components cannot use
9
+ * Node actions): signing, encryption and HTTP/2 to Apple all use Web APIs.
10
+ * Returns `skip` when the delivery is no longer queued.
11
+ */
12
+ export const deliver = internalAction({
13
+ args: { deliveryId: v.id("deliveries") },
14
+ returns: deliverOutcome,
15
+ handler: async (ctx, args) => {
16
+ const job = await ctx.runQuery(internal.queries.loadJob, { deliveryId: args.deliveryId });
17
+ if (!job)
18
+ return { status: "skip" };
19
+ const cache = createTokenCache({
20
+ load: (slot) => ctx.runQuery(internal.queries.loadToken, slot),
21
+ store: (slot, row) => ctx.runMutation(internal.internal_mutations.storeToken, { ...slot, ...row }),
22
+ drop: async (slot) => {
23
+ await ctx.runMutation(internal.internal_mutations.dropToken, slot);
24
+ },
25
+ }, () => Date.now());
26
+ return runSender(job, actionDeps(ctx, env, cache));
27
+ },
28
+ });
29
+ //# sourceMappingURL=actions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actions.js","sourceRoot":"","sources":["../../src/component/actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAY,SAAS,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAuB,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtE;;;;GAIG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,cAAc,CAAC;IACpC,IAAI,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,YAAY,CAAC,EAAE;IACxC,OAAO,EAAE,cAAc;IACvB,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAA2B,EAAE;QACpD,MAAM,GAAG,GAAe,MAAM,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;QACtG,IAAI,CAAC,GAAG;YAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;QACpC,MAAM,KAAK,GAAG,gBAAgB,CAC5B;YACE,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC;YAC9D,KAAK,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,kBAAkB,CAAC,UAAU,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,GAAG,EAAE,CAAC;YAClG,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;gBACnB,MAAM,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,kBAAkB,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;YACrE,CAAC;SACF,EACD,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CACjB,CAAC;QACF,OAAO,SAAS,CAAC,GAAG,EAAE,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;IACrD,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,27 @@
1
+ import type { PushData, SendConfig, SendInput } from "./validators.js";
2
+ /**
3
+ * Check flat data: at most 100 keys, no reserved keys, finite numbers, bounded strings.
4
+ * @param data - The data record.
5
+ */
6
+ export declare function checkData(data: PushData): void;
7
+ /**
8
+ * Validate one message before anything is written. Bad `rawJson` is refused here.
9
+ * @param input - The message.
10
+ */
11
+ export declare function checkSendInput(input: SendInput): void;
12
+ /**
13
+ * Validate the mount-wide settings the client passes with every send.
14
+ * @param config - Send settings.
15
+ */
16
+ export declare function checkSendConfig(config: SendConfig): void;
17
+ /**
18
+ * Whether a string has the form of a Convex function handle. Handles are made
19
+ * by `createFunctionHandle` in the host; a plain function name is refused, so a
20
+ * stored value is not taken as one of the component's own function names. This
21
+ * is a form check, not a security boundary: the host is trusted to pass its
22
+ * own handles.
23
+ * @param value - The stored or supplied string.
24
+ * @returns Whether it starts with `function://`.
25
+ */
26
+ export declare function isHandleString(value: string): boolean;
27
+ //# sourceMappingURL=checks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checks.d.ts","sourceRoot":"","sources":["../../src/component/checks.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAqBvE;;;GAGG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,CAa9C;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAwBrD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAgBxD;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAErD"}
@@ -0,0 +1,107 @@
1
+ import { MAX_COLLAPSE_KEY_BYTES, MAX_DATA_KEYS, MAX_DEVICES_PER_MESSAGE, MAX_MAX_ATTEMPTS, MAX_MAX_PARALLELISM, MAX_REF_LENGTH, MAX_TEXT_LENGTH, MAX_TTL_SECONDS, } from "../shared.js";
2
+ import { byteLength } from "./crypto/codec.js";
3
+ import { parseRawJson } from "./providers/payload.js";
4
+ import { checkRef, fail } from "./registry.js";
5
+ /** Data keys APNs or FCM reserve for themselves. */
6
+ const RESERVED_DATA_KEYS = new Set(["aps", "from", "notification", "message_type", "collapse_key"]);
7
+ /** Values sent as HTTP header values: printable ASCII (the APNs topic also without spaces). */
8
+ const HEADER_TEXT = /^[\x20-\x7e]+$/;
9
+ const HEADER_TOKEN = /^[\x21-\x7e]+$/;
10
+ function checkText(field, value, max = MAX_TEXT_LENGTH) {
11
+ if (value !== undefined && value.length > max) {
12
+ fail("INVALID_ARGUMENT", `${field} must be at most ${String(max)} characters`);
13
+ }
14
+ }
15
+ function checkInteger(field, value, min, max) {
16
+ if (value !== undefined && !(Number.isInteger(value) && value >= min && value <= max)) {
17
+ fail("INVALID_ARGUMENT", `${field} must be an integer from ${String(min)} to ${String(max)}`);
18
+ }
19
+ }
20
+ /**
21
+ * Check flat data: at most 100 keys, no reserved keys, finite numbers, bounded strings.
22
+ * @param data - The data record.
23
+ */
24
+ export function checkData(data) {
25
+ const entries = Object.entries(data);
26
+ if (entries.length > MAX_DATA_KEYS)
27
+ fail("INVALID_DATA", `data must have at most ${String(MAX_DATA_KEYS)} keys`);
28
+ for (const [key, value] of entries) {
29
+ if (key.length === 0 || key.length > MAX_REF_LENGTH)
30
+ fail("INVALID_DATA", "data keys must be 1 to 256 characters");
31
+ if (RESERVED_DATA_KEYS.has(key) || key.startsWith("google.") || key.startsWith("gcm.")) {
32
+ fail("INVALID_DATA", `data key "${key}" is reserved by a provider`);
33
+ }
34
+ if (typeof value === "number" && !Number.isFinite(value))
35
+ fail("INVALID_DATA", `data value for "${key}" must be finite`);
36
+ if (typeof value === "string" && value.length > MAX_TEXT_LENGTH) {
37
+ fail("INVALID_DATA", `data value for "${key}" must be at most ${String(MAX_TEXT_LENGTH)} characters`);
38
+ }
39
+ }
40
+ }
41
+ /**
42
+ * Validate one message before anything is written. Bad `rawJson` is refused here.
43
+ * @param input - The message.
44
+ */
45
+ export function checkSendInput(input) {
46
+ if ("subjectRef" in input.to)
47
+ checkRef("to.subjectRef", input.to.subjectRef);
48
+ else if (input.to.deviceIds.length === 0 || input.to.deviceIds.length > MAX_DEVICES_PER_MESSAGE) {
49
+ fail("INVALID_ARGUMENT", `to.deviceIds must list 1 to ${String(MAX_DEVICES_PER_MESSAGE)} devices`);
50
+ }
51
+ checkText("title", input.title);
52
+ checkText("body", input.body);
53
+ checkData(input.data ?? {});
54
+ if (input.collapseKey !== undefined && !(HEADER_TEXT.test(input.collapseKey) && byteLength(input.collapseKey) <= MAX_COLLAPSE_KEY_BYTES)) {
55
+ fail("INVALID_ARGUMENT", `collapseKey must be 1 to ${String(MAX_COLLAPSE_KEY_BYTES)} printable ASCII characters`);
56
+ }
57
+ checkInteger("ttlSeconds", input.ttlSeconds, 0, MAX_TTL_SECONDS);
58
+ checkInteger("badge", input.badge, 0, 1_000_000);
59
+ checkText("sound", input.sound, MAX_REF_LENGTH);
60
+ checkText("category", input.category, MAX_REF_LENGTH);
61
+ if (input.idempotencyKey !== undefined)
62
+ checkRef("idempotencyKey", input.idempotencyKey);
63
+ const { apns, fcm, webpush } = input.overrides ?? {};
64
+ checkText("overrides.apns.threadId", apns?.threadId, MAX_REF_LENGTH);
65
+ checkText("overrides.fcm.channelId", fcm?.channelId, MAX_REF_LENGTH);
66
+ checkText("overrides.webpush.icon", webpush?.icon, MAX_TEXT_LENGTH);
67
+ checkText("overrides.webpush.url", webpush?.url, MAX_TEXT_LENGTH);
68
+ for (const [slot, raw] of [["apns", apns?.rawJson], ["fcm", fcm?.rawJson], ["webpush", webpush?.rawJson]]) {
69
+ if (parseRawJson(raw) === null)
70
+ fail("INVALID_RAW_JSON", `overrides.${slot}.rawJson must be a JSON object of at most 4096 characters`);
71
+ }
72
+ }
73
+ /**
74
+ * Validate the mount-wide settings the client passes with every send.
75
+ * @param config - Send settings.
76
+ */
77
+ export function checkSendConfig(config) {
78
+ checkInteger("maxAttempts", config.maxAttempts, 1, MAX_MAX_ATTEMPTS);
79
+ checkInteger("maxParallelism", config.maxParallelism, 1, MAX_MAX_PARALLELISM);
80
+ for (const { appRef, app } of config.apps) {
81
+ checkRef("appRef", appRef);
82
+ if (app.platform === "apns" && !HEADER_TOKEN.test(app.topic)) {
83
+ fail("INVALID_ARGUMENT", `app ${appRef} topic must be printable ASCII without spaces`);
84
+ }
85
+ }
86
+ for (const { provider, handle } of config.providers) {
87
+ checkRef("provider", provider);
88
+ if (!isHandleString(handle))
89
+ fail("INVALID_ARGUMENT", `provider ${provider} needs a function handle`);
90
+ }
91
+ if (config.onDeliveryHandle !== undefined && !isHandleString(config.onDeliveryHandle)) {
92
+ fail("INVALID_ARGUMENT", "onDeliveryHandle must be a function handle");
93
+ }
94
+ }
95
+ /**
96
+ * Whether a string has the form of a Convex function handle. Handles are made
97
+ * by `createFunctionHandle` in the host; a plain function name is refused, so a
98
+ * stored value is not taken as one of the component's own function names. This
99
+ * is a form check, not a security boundary: the host is trusted to pass its
100
+ * own handles.
101
+ * @param value - The stored or supplied string.
102
+ * @returns Whether it starts with `function://`.
103
+ */
104
+ export function isHandleString(value) {
105
+ return value.startsWith("function://");
106
+ }
107
+ //# sourceMappingURL=checks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checks.js","sourceRoot":"","sources":["../../src/component/checks.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,aAAa,EACb,uBAAuB,EACvB,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,eAAe,GAChB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAG/C,oDAAoD;AACpD,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,CAAC,CAAC,CAAC;AAEpG,+FAA+F;AAC/F,MAAM,WAAW,GAAG,g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and
3
+ * its deliveries fail with `PROVIDER_NOT_CONFIGURED`. The host binds them at
4
+ * mount: `app.use(push, { env: { APNS_KEY_P8: app.env.APNS_KEY_P8, ... } })`.
5
+ */
6
+ declare const component: import("convex/server").ComponentDefinition<any, {
7
+ readonly APNS_KEY_P8: import("convex/values").VString<string | undefined, "optional">;
8
+ readonly APNS_KEY_ID: import("convex/values").VString<string | undefined, "optional">;
9
+ readonly APNS_TEAM_ID: import("convex/values").VString<string | undefined, "optional">;
10
+ readonly APNS_SANDBOX_KEY_P8: import("convex/values").VString<string | undefined, "optional">;
11
+ readonly APNS_SANDBOX_KEY_ID: import("convex/values").VString<string | undefined, "optional">;
12
+ readonly FCM_SERVICE_ACCOUNT_JSON: import("convex/values").VString<string | undefined, "optional">;
13
+ readonly VAPID_PUBLIC_KEY: import("convex/values").VString<string | undefined, "optional">;
14
+ readonly VAPID_PRIVATE_KEY: import("convex/values").VString<string | undefined, "optional">;
15
+ readonly VAPID_SUBJECT: import("convex/values").VString<string | undefined, "optional">;
16
+ }>;
17
+ export default component;
18
+ //# sourceMappingURL=convex.config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convex.config.d.ts","sourceRoot":"","sources":["../../src/component/convex.config.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,QAAA,MAAM,SAAS;;;;;;;;;;EAYb,CAAC;eASY,SAAS"}
@@ -0,0 +1,30 @@
1
+ import rateLimiter from "@convex-dev/rate-limiter/convex.config.js";
2
+ import workpool from "@convex-dev/workpool/convex.config.js";
3
+ import { defineComponent } from "convex/server";
4
+ import { v } from "convex/values";
5
+ /**
6
+ * Every variable is optional. A provider without its keys is switched off and
7
+ * its deliveries fail with `PROVIDER_NOT_CONFIGURED`. The host binds them at
8
+ * mount: `app.use(push, { env: { APNS_KEY_P8: app.env.APNS_KEY_P8, ... } })`.
9
+ */
10
+ const component = defineComponent("push", {
11
+ env: {
12
+ APNS_KEY_P8: v.optional(v.string()),
13
+ APNS_KEY_ID: v.optional(v.string()),
14
+ APNS_TEAM_ID: v.optional(v.string()),
15
+ APNS_SANDBOX_KEY_P8: v.optional(v.string()),
16
+ APNS_SANDBOX_KEY_ID: v.optional(v.string()),
17
+ FCM_SERVICE_ACCOUNT_JSON: v.optional(v.string()),
18
+ VAPID_PUBLIC_KEY: v.optional(v.string()),
19
+ VAPID_PRIVATE_KEY: v.optional(v.string()),
20
+ VAPID_SUBJECT: v.optional(v.string()),
21
+ },
22
+ });
23
+ /** One queue per provider, so a slow or throttled provider never holds up the others. */
24
+ component.use(workpool, { name: "apnsPool" });
25
+ component.use(workpool, { name: "fcmPool" });
26
+ component.use(workpool, { name: "webpushPool" });
27
+ component.use(workpool, { name: "customPool" });
28
+ component.use(rateLimiter);
29
+ export default component;
30
+ //# sourceMappingURL=convex.config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convex.config.js","sourceRoot":"","sources":["../../src/component/convex.config.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,2CAA2C,CAAC;AACpE,OAAO,QAAQ,MAAM,uCAAuC,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAElC;;;;GAIG;AACH,MAAM,SAAS,GAAG,eAAe,CAAC,MAAM,EAAE;IACxC,GAAG,EAAE;QACH,WAAW,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QACnC,WAAW,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QACnC,YAAY,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QACpC,mBAAmB,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAC3C,mBAAmB,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAC3C,wBAAwB,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAChD,gBAAgB,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QACxC,iBAAiB,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QACzC,aAAa,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;KACtC;CACF,CAAC,CAAC;AAEH,yFAAyF;AACzF,SAAS,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC;AAC9C,SAAS,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;AAC7C,SAAS,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC;AACjD,SAAS,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC;AAChD,SAAS,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;AAE3B,eAAe,SAAS,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Daily prune with the default 30-day retention. Cron definitions are static
3
+ * per deployment; a host that wants another window calls `prune` itself.
4
+ */
5
+ declare const crons: import("convex/server").Crons;
6
+ /** The component's cron jobs. */
7
+ export default crons;
8
+ //# sourceMappingURL=crons.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crons.d.ts","sourceRoot":"","sources":["../../src/component/crons.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,QAAA,MAAM,KAAK,+BAAa,CAAC;AAOzB,iCAAiC;eAClB,KAAK"}
@@ -0,0 +1,15 @@
1
+ import { cronJobs } from "convex/server";
2
+ import { DEFAULT_PRUNE_BATCH, DEFAULT_RETENTION_MS } from "../shared.js";
3
+ import { api } from "./_generated/api.js";
4
+ /**
5
+ * Daily prune with the default 30-day retention. Cron definitions are static
6
+ * per deployment; a host that wants another window calls `prune` itself.
7
+ */
8
+ const crons = cronJobs();
9
+ crons.interval("push:prune", { hours: 24 }, api.mutations.prune, {
10
+ retentionMs: DEFAULT_RETENTION_MS,
11
+ batch: DEFAULT_PRUNE_BATCH,
12
+ });
13
+ /** The component's cron jobs. */
14
+ export default crons;
15
+ //# sourceMappingURL=crons.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crons.js","sourceRoot":"","sources":["../../src/component/crons.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAE1C;;;GAGG;AACH,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;AAEzB,KAAK,CAAC,QAAQ,CAAC,YAAY,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC,SAAS,CAAC,KAAK,EAAE;IAC/D,WAAW,EAAE,oBAAoB;IACjC,KAAK,EAAE,mBAAmB;CAC3B,CAAC,CAAC;AAEH,iCAAiC;AACjC,eAAe,KAAK,CAAC"}
@@ -0,0 +1,64 @@
1
+ /** Byte and text encodings shared by the signers and the encryption code. Web APIs only. */
2
+ /** Bytes backed by a plain ArrayBuffer, as Web Crypto expects. */
3
+ export type Bytes = Uint8Array<ArrayBuffer>;
4
+ /**
5
+ * Encode text as UTF-8.
6
+ * @param text - Any string.
7
+ * @returns Its UTF-8 bytes.
8
+ */
9
+ export declare function utf8(text: string): Bytes;
10
+ /**
11
+ * Decode UTF-8 bytes.
12
+ * @param bytes - UTF-8 bytes.
13
+ * @returns The decoded string.
14
+ */
15
+ export declare function fromUtf8(bytes: Uint8Array): string;
16
+ /**
17
+ * Concatenate byte arrays.
18
+ * @param parts - Arrays to join, in order.
19
+ * @returns One array.
20
+ */
21
+ export declare function concat(...parts: Uint8Array[]): Bytes;
22
+ /**
23
+ * Copy any byte view into a fresh ArrayBuffer-backed array.
24
+ * @param input - An ArrayBuffer or byte view.
25
+ * @returns A copy.
26
+ */
27
+ export declare function toBytes(input: ArrayBuffer | Uint8Array): Bytes;
28
+ /**
29
+ * Encode bytes as unpadded base64url (RFC 4648 section 5).
30
+ * @param bytes - Bytes to encode.
31
+ * @returns The base64url string.
32
+ */
33
+ export declare function base64UrlEncode(bytes: Uint8Array): string;
34
+ /**
35
+ * Decode base64 or base64url, padded or not.
36
+ * @param text - The encoded string. Whitespace is ignored.
37
+ * @returns The bytes, or `null` when the input is not base64.
38
+ */
39
+ export declare function base64Decode(text: string): Bytes | null;
40
+ /**
41
+ * Encode bytes as lowercase hex.
42
+ * @param bytes - Bytes to encode.
43
+ * @returns The hex string.
44
+ */
45
+ export declare function toHex(bytes: Uint8Array): string;
46
+ /**
47
+ * SHA-256 of a string, as hex.
48
+ * @param text - Input text, hashed as UTF-8.
49
+ * @returns 64 hex characters.
50
+ */
51
+ export declare function sha256Hex(text: string): Promise<string>;
52
+ /**
53
+ * SHA-256 of a string, as base64url.
54
+ * @param text - Input text, hashed as UTF-8.
55
+ * @returns 43 base64url characters.
56
+ */
57
+ export declare function sha256Base64Url(text: string): Promise<string>;
58
+ /**
59
+ * Size of a string in UTF-8 bytes.
60
+ * @param text - Any string.
61
+ * @returns The byte length.
62
+ */
63
+ export declare function byteLength(text: string): number;
64
+ //# sourceMappingURL=codec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../../src/component/crypto/codec.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAE5F,kEAAkE;AAClE,MAAM,MAAM,KAAK,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;AAK5C;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAExC;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAElD;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,GAAG,KAAK,EAAE,UAAU,EAAE,GAAG,KAAK,CAQpD;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,WAAW,GAAG,UAAU,GAAG,KAAK,CAE9D;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAIzD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI,CAUvD;AAED;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAE/C;AAED;;;;GAIG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAE7D;AAED;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAEnE;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE/C"}