@shdan/submesh 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (230) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +62 -0
  3. package/dist/contracts.d.ts +191 -0
  4. package/dist/contracts.d.ts.map +1 -0
  5. package/dist/contracts.js +2 -0
  6. package/dist/contracts.js.map +1 -0
  7. package/dist/drizzle/catalog-mapping-repository.d.ts +280 -0
  8. package/dist/drizzle/catalog-mapping-repository.d.ts.map +1 -0
  9. package/dist/drizzle/catalog-mapping-repository.js +62 -0
  10. package/dist/drizzle/catalog-mapping-repository.js.map +1 -0
  11. package/dist/drizzle/ensure-schema.d.ts +3 -0
  12. package/dist/drizzle/ensure-schema.d.ts.map +1 -0
  13. package/dist/drizzle/ensure-schema.js +100 -0
  14. package/dist/drizzle/ensure-schema.js.map +1 -0
  15. package/dist/drizzle/inbound-event-repository.d.ts +960 -0
  16. package/dist/drizzle/inbound-event-repository.d.ts.map +1 -0
  17. package/dist/drizzle/inbound-event-repository.js +148 -0
  18. package/dist/drizzle/inbound-event-repository.js.map +1 -0
  19. package/dist/drizzle/index.d.ts +40 -0
  20. package/dist/drizzle/index.d.ts.map +1 -0
  21. package/dist/drizzle/index.js +57 -0
  22. package/dist/drizzle/index.js.map +1 -0
  23. package/dist/drizzle/migrate.d.ts +11 -0
  24. package/dist/drizzle/migrate.d.ts.map +1 -0
  25. package/dist/drizzle/migrate.js +22 -0
  26. package/dist/drizzle/migrate.js.map +1 -0
  27. package/dist/drizzle/plan-repository.d.ts +497 -0
  28. package/dist/drizzle/plan-repository.d.ts.map +1 -0
  29. package/dist/drizzle/plan-repository.js +70 -0
  30. package/dist/drizzle/plan-repository.js.map +1 -0
  31. package/dist/drizzle/plugin-installation-repository.d.ts +26 -0
  32. package/dist/drizzle/plugin-installation-repository.d.ts.map +1 -0
  33. package/dist/drizzle/plugin-installation-repository.js +71 -0
  34. package/dist/drizzle/plugin-installation-repository.js.map +1 -0
  35. package/dist/drizzle/repository-set.d.ts +4 -0
  36. package/dist/drizzle/repository-set.d.ts.map +1 -0
  37. package/dist/drizzle/repository-set.js +19 -0
  38. package/dist/drizzle/repository-set.js.map +1 -0
  39. package/dist/drizzle/schema.d.ts +2370 -0
  40. package/dist/drizzle/schema.d.ts.map +1 -0
  41. package/dist/drizzle/schema.js +103 -0
  42. package/dist/drizzle/schema.js.map +1 -0
  43. package/dist/drizzle/subject-repository.d.ts +295 -0
  44. package/dist/drizzle/subject-repository.d.ts.map +1 -0
  45. package/dist/drizzle/subject-repository.js +76 -0
  46. package/dist/drizzle/subject-repository.js.map +1 -0
  47. package/dist/drizzle/subscription-repository.d.ts +60 -0
  48. package/dist/drizzle/subscription-repository.d.ts.map +1 -0
  49. package/dist/drizzle/subscription-repository.js +128 -0
  50. package/dist/drizzle/subscription-repository.js.map +1 -0
  51. package/dist/drizzle/summary-repository.d.ts +9 -0
  52. package/dist/drizzle/summary-repository.d.ts.map +1 -0
  53. package/dist/drizzle/summary-repository.js +25 -0
  54. package/dist/drizzle/summary-repository.js.map +1 -0
  55. package/dist/drizzle/types.d.ts +4 -0
  56. package/dist/drizzle/types.d.ts.map +1 -0
  57. package/dist/drizzle/types.js +2 -0
  58. package/dist/drizzle/types.js.map +1 -0
  59. package/dist/errors.d.ts +10 -0
  60. package/dist/errors.d.ts.map +1 -0
  61. package/dist/errors.js +13 -0
  62. package/dist/errors.js.map +1 -0
  63. package/dist/hooks.d.ts +24 -0
  64. package/dist/hooks.d.ts.map +1 -0
  65. package/dist/hooks.js +2 -0
  66. package/dist/hooks.js.map +1 -0
  67. package/dist/index.d.ts +11 -0
  68. package/dist/index.d.ts.map +1 -0
  69. package/dist/index.js +9 -0
  70. package/dist/index.js.map +1 -0
  71. package/dist/logger.d.ts +16 -0
  72. package/dist/logger.d.ts.map +1 -0
  73. package/dist/logger.js +8 -0
  74. package/dist/logger.js.map +1 -0
  75. package/dist/plugins/builtin-plugins.d.ts +3 -0
  76. package/dist/plugins/builtin-plugins.d.ts.map +1 -0
  77. package/dist/plugins/builtin-plugins.js +7 -0
  78. package/dist/plugins/builtin-plugins.js.map +1 -0
  79. package/dist/plugins/hash-payload.d.ts +2 -0
  80. package/dist/plugins/hash-payload.d.ts.map +1 -0
  81. package/dist/plugins/hash-payload.js +5 -0
  82. package/dist/plugins/hash-payload.js.map +1 -0
  83. package/dist/plugins/manual.d.ts +12 -0
  84. package/dist/plugins/manual.d.ts.map +1 -0
  85. package/dist/plugins/manual.js +87 -0
  86. package/dist/plugins/manual.js.map +1 -0
  87. package/dist/plugins/plan-provisioning.d.ts +18 -0
  88. package/dist/plugins/plan-provisioning.d.ts.map +1 -0
  89. package/dist/plugins/plan-provisioning.js +159 -0
  90. package/dist/plugins/plan-provisioning.js.map +1 -0
  91. package/dist/plugins/plugin-registry.d.ts +9 -0
  92. package/dist/plugins/plugin-registry.d.ts.map +1 -0
  93. package/dist/plugins/plugin-registry.js +18 -0
  94. package/dist/plugins/plugin-registry.js.map +1 -0
  95. package/dist/providers/apple/plugin/app-store-plan-sync.d.ts +4 -0
  96. package/dist/providers/apple/plugin/app-store-plan-sync.d.ts.map +1 -0
  97. package/dist/providers/apple/plugin/app-store-plan-sync.js +85 -0
  98. package/dist/providers/apple/plugin/app-store-plan-sync.js.map +1 -0
  99. package/dist/providers/apple/plugin/app-store.d.ts +20 -0
  100. package/dist/providers/apple/plugin/app-store.d.ts.map +1 -0
  101. package/dist/providers/apple/plugin/app-store.js +397 -0
  102. package/dist/providers/apple/plugin/app-store.js.map +1 -0
  103. package/dist/providers/apple/security/app-store-verification.d.ts +4 -0
  104. package/dist/providers/apple/security/app-store-verification.d.ts.map +1 -0
  105. package/dist/providers/apple/security/app-store-verification.js +100 -0
  106. package/dist/providers/apple/security/app-store-verification.js.map +1 -0
  107. package/dist/providers/apple/services/app-store-subscription-verification-service.d.ts +3 -0
  108. package/dist/providers/apple/services/app-store-subscription-verification-service.d.ts.map +1 -0
  109. package/dist/providers/apple/services/app-store-subscription-verification-service.js +155 -0
  110. package/dist/providers/apple/services/app-store-subscription-verification-service.js.map +1 -0
  111. package/dist/providers/google/plugin/play-plan-sync.d.ts +4 -0
  112. package/dist/providers/google/plugin/play-plan-sync.d.ts.map +1 -0
  113. package/dist/providers/google/plugin/play-plan-sync.js +270 -0
  114. package/dist/providers/google/plugin/play-plan-sync.js.map +1 -0
  115. package/dist/providers/google/plugin/play.d.ts +20 -0
  116. package/dist/providers/google/plugin/play.d.ts.map +1 -0
  117. package/dist/providers/google/plugin/play.js +460 -0
  118. package/dist/providers/google/plugin/play.js.map +1 -0
  119. package/dist/providers/google/security/oauth.d.ts +10 -0
  120. package/dist/providers/google/security/oauth.d.ts.map +1 -0
  121. package/dist/providers/google/security/oauth.js +116 -0
  122. package/dist/providers/google/security/oauth.js.map +1 -0
  123. package/dist/providers/google/security/pubsub-verification.d.ts +3 -0
  124. package/dist/providers/google/security/pubsub-verification.d.ts.map +1 -0
  125. package/dist/providers/google/security/pubsub-verification.js +229 -0
  126. package/dist/providers/google/security/pubsub-verification.js.map +1 -0
  127. package/dist/providers/google/services/play-subscription-verification-service.d.ts +3 -0
  128. package/dist/providers/google/services/play-subscription-verification-service.d.ts.map +1 -0
  129. package/dist/providers/google/services/play-subscription-verification-service.js +96 -0
  130. package/dist/providers/google/services/play-subscription-verification-service.js.map +1 -0
  131. package/dist/repositories/catalog-mapping-repository.d.ts +9 -0
  132. package/dist/repositories/catalog-mapping-repository.d.ts.map +1 -0
  133. package/dist/repositories/catalog-mapping-repository.js +2 -0
  134. package/dist/repositories/catalog-mapping-repository.js.map +1 -0
  135. package/dist/repositories/inbound-event-repository.d.ts +23 -0
  136. package/dist/repositories/inbound-event-repository.d.ts.map +1 -0
  137. package/dist/repositories/inbound-event-repository.js +2 -0
  138. package/dist/repositories/inbound-event-repository.js.map +1 -0
  139. package/dist/repositories/index.d.ts +30 -0
  140. package/dist/repositories/index.d.ts.map +1 -0
  141. package/dist/repositories/index.js +2 -0
  142. package/dist/repositories/index.js.map +1 -0
  143. package/dist/repositories/plan-repository.d.ts +10 -0
  144. package/dist/repositories/plan-repository.d.ts.map +1 -0
  145. package/dist/repositories/plan-repository.js +2 -0
  146. package/dist/repositories/plan-repository.js.map +1 -0
  147. package/dist/repositories/plugin-installation-repository.d.ts +13 -0
  148. package/dist/repositories/plugin-installation-repository.d.ts.map +1 -0
  149. package/dist/repositories/plugin-installation-repository.js +2 -0
  150. package/dist/repositories/plugin-installation-repository.js.map +1 -0
  151. package/dist/repositories/subject-repository.d.ts +10 -0
  152. package/dist/repositories/subject-repository.d.ts.map +1 -0
  153. package/dist/repositories/subject-repository.js +2 -0
  154. package/dist/repositories/subject-repository.js.map +1 -0
  155. package/dist/repositories/subscription-repository.d.ts +24 -0
  156. package/dist/repositories/subscription-repository.d.ts.map +1 -0
  157. package/dist/repositories/subscription-repository.js +2 -0
  158. package/dist/repositories/subscription-repository.js.map +1 -0
  159. package/dist/security/jwt.d.ts +22 -0
  160. package/dist/security/jwt.d.ts.map +1 -0
  161. package/dist/security/jwt.js +132 -0
  162. package/dist/security/jwt.js.map +1 -0
  163. package/dist/security/plugin-webhook-verification.d.ts +3 -0
  164. package/dist/security/plugin-webhook-verification.d.ts.map +1 -0
  165. package/dist/security/plugin-webhook-verification.js +44 -0
  166. package/dist/security/plugin-webhook-verification.js.map +1 -0
  167. package/dist/security/relay-signature.d.ts +12 -0
  168. package/dist/security/relay-signature.d.ts.map +1 -0
  169. package/dist/security/relay-signature.js +39 -0
  170. package/dist/security/relay-signature.js.map +1 -0
  171. package/dist/services/canonical-subscription-service.d.ts +4 -0
  172. package/dist/services/canonical-subscription-service.d.ts.map +1 -0
  173. package/dist/services/canonical-subscription-service.js +20 -0
  174. package/dist/services/canonical-subscription-service.js.map +1 -0
  175. package/dist/services/managed-subscription-service.d.ts +5 -0
  176. package/dist/services/managed-subscription-service.d.ts.map +1 -0
  177. package/dist/services/managed-subscription-service.js +24 -0
  178. package/dist/services/managed-subscription-service.js.map +1 -0
  179. package/dist/services/plan-provisioning-service.d.ts +5 -0
  180. package/dist/services/plan-provisioning-service.d.ts.map +1 -0
  181. package/dist/services/plan-provisioning-service.js +100 -0
  182. package/dist/services/plan-provisioning-service.js.map +1 -0
  183. package/dist/services/plan-resolution.d.ts +4 -0
  184. package/dist/services/plan-resolution.d.ts.map +1 -0
  185. package/dist/services/plan-resolution.js +33 -0
  186. package/dist/services/plan-resolution.js.map +1 -0
  187. package/dist/services/plugin-installation-service.d.ts +6 -0
  188. package/dist/services/plugin-installation-service.d.ts.map +1 -0
  189. package/dist/services/plugin-installation-service.js +19 -0
  190. package/dist/services/plugin-installation-service.js.map +1 -0
  191. package/dist/services/provider-subscription-sync-service.d.ts +4 -0
  192. package/dist/services/provider-subscription-sync-service.d.ts.map +1 -0
  193. package/dist/services/provider-subscription-sync-service.js +13 -0
  194. package/dist/services/provider-subscription-sync-service.js.map +1 -0
  195. package/dist/services/subject-resolution.d.ts +4 -0
  196. package/dist/services/subject-resolution.d.ts.map +1 -0
  197. package/dist/services/subject-resolution.js +48 -0
  198. package/dist/services/subject-resolution.js.map +1 -0
  199. package/dist/services/webhook-ingestion-service.d.ts +14 -0
  200. package/dist/services/webhook-ingestion-service.d.ts.map +1 -0
  201. package/dist/services/webhook-ingestion-service.js +149 -0
  202. package/dist/services/webhook-ingestion-service.js.map +1 -0
  203. package/dist/submesh.d.ts +265 -0
  204. package/dist/submesh.d.ts.map +1 -0
  205. package/dist/submesh.js +602 -0
  206. package/dist/submesh.js.map +1 -0
  207. package/dist/utils/canonical.d.ts +7 -0
  208. package/dist/utils/canonical.d.ts.map +1 -0
  209. package/dist/utils/canonical.js +8 -0
  210. package/dist/utils/canonical.js.map +1 -0
  211. package/dist/utils/parse.d.ts +42 -0
  212. package/dist/utils/parse.d.ts.map +1 -0
  213. package/dist/utils/parse.js +74 -0
  214. package/dist/utils/parse.js.map +1 -0
  215. package/dist/utils/records.d.ts +2 -0
  216. package/dist/utils/records.d.ts.map +1 -0
  217. package/dist/utils/records.js +7 -0
  218. package/dist/utils/records.js.map +1 -0
  219. package/dist/utils/time.d.ts +2 -0
  220. package/dist/utils/time.d.ts.map +1 -0
  221. package/dist/utils/time.js +4 -0
  222. package/dist/utils/time.js.map +1 -0
  223. package/dist/utils/validation.d.ts +10 -0
  224. package/dist/utils/validation.d.ts.map +1 -0
  225. package/dist/utils/validation.js +19 -0
  226. package/dist/utils/validation.js.map +1 -0
  227. package/drizzle/0000_cute_the_order.sql +94 -0
  228. package/drizzle/meta/0000_snapshot.json +559 -0
  229. package/drizzle/meta/_journal.json +13 -0
  230. package/package.json +54 -0
@@ -0,0 +1,229 @@
1
+ import { verifySignedTokenSignature } from "../../../security/jwt.js";
2
+ const DEFAULT_CERTS_URL = "https://www.googleapis.com/oauth2/v1/certs";
3
+ const CLOCK_SKEW_SECONDS = 300;
4
+ const DEFAULT_TRUSTED_CERT_HOSTS = new Set([
5
+ "www.googleapis.com",
6
+ "oauth2.googleapis.com",
7
+ ]);
8
+ const MAX_CERT_CACHE_SIZE = 20;
9
+ const certCache = new Map();
10
+ function readHeader(headers, key) {
11
+ const value = headers[key] ?? headers[key.toLowerCase()];
12
+ return Array.isArray(value) ? value[0] : value;
13
+ }
14
+ function getBearerToken(headers) {
15
+ const authorization = readHeader(headers, "authorization");
16
+ if (!authorization) {
17
+ return undefined;
18
+ }
19
+ const [scheme, token] = authorization.split(/\s+/, 2);
20
+ if (!scheme || !token || scheme.toLowerCase() !== "bearer") {
21
+ return undefined;
22
+ }
23
+ return token;
24
+ }
25
+ function getStringRecord(value) {
26
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
27
+ return {};
28
+ }
29
+ return Object.fromEntries(Object.entries(value).filter((entry) => typeof entry[1] === "string"));
30
+ }
31
+ function getString(value) {
32
+ return typeof value === "string" && value.length > 0 ? value : undefined;
33
+ }
34
+ function getStringArray(value) {
35
+ if (!Array.isArray(value)) {
36
+ return [];
37
+ }
38
+ return value.filter((entry) => typeof entry === "string" && entry.length > 0);
39
+ }
40
+ function isExplicitlyEnabled(value) {
41
+ return value === true || value === "true";
42
+ }
43
+ function assertTrustedCertsUrl(certsUrl, config) {
44
+ let parsed;
45
+ try {
46
+ parsed = new URL(certsUrl);
47
+ }
48
+ catch {
49
+ throw new Error(`Invalid Google OpenID certificate URL: ${certsUrl}.`);
50
+ }
51
+ if (parsed.protocol !== "https:") {
52
+ throw new Error("Google OpenID certificate URL must use HTTPS.");
53
+ }
54
+ if (isExplicitlyEnabled(config.allowCustomGoogleOpenIdCertsUrlHost)) {
55
+ return;
56
+ }
57
+ const configuredHosts = new Set(getStringArray(config.googleTrustedOpenIdCertHosts));
58
+ const trustedHosts = configuredHosts.size > 0 ? configuredHosts : DEFAULT_TRUSTED_CERT_HOSTS;
59
+ if (!trustedHosts.has(parsed.hostname)) {
60
+ throw new Error(`Refusing Google OpenID certificate URL host "${parsed.hostname}". Set allowCustomGoogleOpenIdCertsUrlHost=true to override intentionally.`);
61
+ }
62
+ }
63
+ function getNumericDate(value) {
64
+ if (typeof value === "number" && Number.isFinite(value)) {
65
+ return value;
66
+ }
67
+ if (typeof value === "string" && value.length > 0) {
68
+ const parsed = Number(value);
69
+ return Number.isFinite(parsed) ? parsed : undefined;
70
+ }
71
+ return undefined;
72
+ }
73
+ function parseMaxAgeSeconds(value) {
74
+ if (!value) {
75
+ return 3600;
76
+ }
77
+ const match = value.match(/max-age=(\d+)/i);
78
+ return match ? Number(match[1]) : 3600;
79
+ }
80
+ function isAudienceMatch(expected, actual) {
81
+ if (!expected) {
82
+ return true;
83
+ }
84
+ if (typeof actual === "string") {
85
+ return actual === expected;
86
+ }
87
+ if (Array.isArray(actual)) {
88
+ return actual.includes(expected);
89
+ }
90
+ return false;
91
+ }
92
+ async function loadGoogleOpenIdCertificates(config) {
93
+ const inline = getStringRecord(config.googleOpenIdPublicKeys);
94
+ if (Object.keys(inline).length > 0) {
95
+ return inline;
96
+ }
97
+ const certsUrl = getString(config.googleOpenIdCertsUrl) ?? DEFAULT_CERTS_URL;
98
+ assertTrustedCertsUrl(certsUrl, config);
99
+ const cached = certCache.get(certsUrl);
100
+ if (cached && cached.expiresAt > Date.now()) {
101
+ return cached.certs;
102
+ }
103
+ const response = await fetch(certsUrl);
104
+ if (!response.ok) {
105
+ throw new Error(`Failed to load Google public certificates from ${certsUrl}.`);
106
+ }
107
+ const payload = getStringRecord(await response.json());
108
+ if (Object.keys(payload).length === 0) {
109
+ throw new Error("Google public certificate response did not contain any certificates.");
110
+ }
111
+ certCache.set(certsUrl, {
112
+ expiresAt: Date.now() + parseMaxAgeSeconds(response.headers.get("cache-control")) * 1000,
113
+ certs: payload,
114
+ });
115
+ for (const [key, entry] of certCache.entries()) {
116
+ if (entry.expiresAt <= Date.now()) {
117
+ certCache.delete(key);
118
+ }
119
+ }
120
+ if (certCache.size > MAX_CERT_CACHE_SIZE) {
121
+ const firstKey = certCache.keys().next().value;
122
+ if (firstKey !== undefined) {
123
+ certCache.delete(firstKey);
124
+ }
125
+ }
126
+ return payload;
127
+ }
128
+ function hasGoogleVerificationConfig(config) {
129
+ return (typeof config.googlePubSubAudience === "string" ||
130
+ typeof config.googlePubSubServiceAccountEmail === "string" ||
131
+ Object.keys(getStringRecord(config.googleOpenIdPublicKeys)).length > 0 ||
132
+ typeof config.googleOpenIdCertsUrl === "string");
133
+ }
134
+ export async function verifyGooglePubSubWebhook(envelope, config) {
135
+ if (!hasGoogleVerificationConfig(config)) {
136
+ return undefined;
137
+ }
138
+ const token = getBearerToken(envelope.headers);
139
+ if (!token) {
140
+ return {
141
+ verified: false,
142
+ strategy: "custom",
143
+ metadata: {
144
+ provider: "google-play",
145
+ reason: "missing_bearer_token",
146
+ },
147
+ };
148
+ }
149
+ try {
150
+ const certificates = await loadGoogleOpenIdCertificates(config);
151
+ const parsed = verifySignedTokenSignature({
152
+ token,
153
+ algorithm: "RS256",
154
+ publicKeys: typeof parsedKid(token) === "string" && certificates[parsedKid(token)]
155
+ ? [certificates[parsedKid(token)]]
156
+ : Object.values(certificates),
157
+ });
158
+ const payload = parsed.payload;
159
+ const issuer = getString(payload.iss);
160
+ const email = getString(payload.email);
161
+ const expectedAudience = getString(config.googlePubSubAudience);
162
+ const expectedEmail = getString(config.googlePubSubServiceAccountEmail);
163
+ const exp = getNumericDate(payload.exp);
164
+ const nbf = getNumericDate(payload.nbf);
165
+ const nowSeconds = Date.now() / 1000;
166
+ const issuerAllowed = issuer === "accounts.google.com" || issuer === "https://accounts.google.com";
167
+ const audienceAllowed = isAudienceMatch(expectedAudience, payload.aud);
168
+ const emailAllowed = !expectedEmail || email === expectedEmail;
169
+ const emailVerified = payload.email_verified === undefined ||
170
+ payload.email_verified === true ||
171
+ payload.email_verified === "true";
172
+ const timeAllowed = (exp === undefined || nowSeconds <= exp + CLOCK_SKEW_SECONDS) &&
173
+ (nbf === undefined || nowSeconds + CLOCK_SKEW_SECONDS >= nbf);
174
+ if (!issuerAllowed ||
175
+ !audienceAllowed ||
176
+ !emailAllowed ||
177
+ !emailVerified ||
178
+ !timeAllowed) {
179
+ return {
180
+ verified: false,
181
+ strategy: "custom",
182
+ metadata: {
183
+ provider: "google-play",
184
+ issuer,
185
+ audience: payload.aud,
186
+ email,
187
+ },
188
+ };
189
+ }
190
+ return {
191
+ verified: true,
192
+ strategy: "custom",
193
+ metadata: {
194
+ provider: "google-play",
195
+ issuer,
196
+ audience: payload.aud,
197
+ email,
198
+ },
199
+ };
200
+ }
201
+ catch (error) {
202
+ return {
203
+ verified: false,
204
+ strategy: "custom",
205
+ metadata: {
206
+ provider: "google-play",
207
+ error: error instanceof Error ? error.message : "Unknown Google verification error.",
208
+ },
209
+ };
210
+ }
211
+ }
212
+ function parsedKid(token) {
213
+ const [encodedHeader] = token.split(".", 1);
214
+ if (!encodedHeader) {
215
+ return undefined;
216
+ }
217
+ try {
218
+ const raw = Buffer.from(encodedHeader
219
+ .replace(/-/g, "+")
220
+ .replace(/_/g, "/")
221
+ .padEnd(Math.ceil(encodedHeader.length / 4) * 4, "="), "base64").toString("utf8");
222
+ const header = JSON.parse(raw);
223
+ return typeof header.kid === "string" ? header.kid : undefined;
224
+ }
225
+ catch {
226
+ return undefined;
227
+ }
228
+ }
229
+ //# sourceMappingURL=pubsub-verification.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pubsub-verification.js","sourceRoot":"","sources":["../../../../src/providers/google/security/pubsub-verification.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAEtE,MAAM,iBAAiB,GAAG,4CAA4C,CAAC;AACvE,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAC/B,MAAM,0BAA0B,GAAG,IAAI,GAAG,CAAC;IACzC,oBAAoB;IACpB,uBAAuB;CACxB,CAAC,CAAC;AACH,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAE/B,MAAM,SAAS,GAAG,IAAI,GAAG,EAAgE,CAAC;AAE1F,SAAS,UAAU,CACjB,OAAsD,EACtD,GAAW;IAEX,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;IACzD,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AACjD,CAAC;AAED,SAAS,cAAc,CACrB,OAAsD;IAEtD,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IAC3D,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,aAAa,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACtD,IAAI,CAAC,MAAM,IAAI,CAAC,KAAK,IAAI,MAAM,CAAC,WAAW,EAAE,KAAK,QAAQ,EAAE,CAAC;QAC3D,O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AO;YACL,QAAQ,EAAE,KAAK;YACf,QAAQ,EAAE,QAAQ;YAClB,QAAQ,EAAE;gBACR,QAAQ,EAAE,aAAa;gBACvB,KAAK,EACH,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,oCAAoC;aAChF;SACF,CAAC;IACJ,CAAC;AACH,CAAC;AAED,SAAS,SAAS,CAAC,KAAa;IAC9B,MAAM,CAAC,aAAa,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IAC5C,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CACrB,aAAa;aACV,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC;aAClB,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC;aAClB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,EACvD,QAAQ,CACT,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACnB,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAA4B,CAAC;QAC1D,OAAO,OAAO,MAAM,CAAC,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;IACjE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { VerifiedProviderSubscription, VerifyGooglePlaySubscriptionInput } from "../../../contracts.js";
2
+ export declare function verifyGooglePlaySubscription(input: VerifyGooglePlaySubscriptionInput, config?: Record<string, unknown>): Promise<VerifiedProviderSubscription>;
3
+ //# sourceMappingURL=play-subscription-verification-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"play-subscription-verification-service.d.ts","sourceRoot":"","sources":["../../../../src/providers/google/services/play-subscription-verification-service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,4BAA4B,EAC5B,iCAAiC,EAClC,MAAM,uBAAuB,CAAC;AAoH/B,wBAAsB,4BAA4B,CAChD,KAAK,EAAE,iCAAiC,EACxC,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GACnC,OAAO,CAAC,4BAA4B,CAAC,CAmBvC"}
@@ -0,0 +1,96 @@
1
+ import { ValidationError } from "../../../errors.js";
2
+ import { googlePlayPlugin } from "../plugin/play.js";
3
+ import { getGoogleAccessToken } from "../security/oauth.js";
4
+ function asObject(value) {
5
+ return value && typeof value === "object" && !Array.isArray(value)
6
+ ? value
7
+ : {};
8
+ }
9
+ function getString(value) {
10
+ return typeof value === "string" && value.length > 0 ? value : undefined;
11
+ }
12
+ function readGoogleServiceAccount(value) {
13
+ const record = asObject(value);
14
+ const clientEmail = getString(record.clientEmail);
15
+ const privateKey = getString(record.privateKey);
16
+ if (!clientEmail || !privateKey) {
17
+ return undefined;
18
+ }
19
+ return {
20
+ clientEmail,
21
+ privateKey,
22
+ privateKeyId: getString(record.privateKeyId),
23
+ tokenUri: getString(record.tokenUri),
24
+ scope: getString(record.scope),
25
+ };
26
+ }
27
+ function resolvePackageName(input, config) {
28
+ const planSync = asObject(config.planSync);
29
+ const googlePlay = asObject(config.googlePlay);
30
+ const packageName = input.packageName ??
31
+ getString(googlePlay.packageName) ??
32
+ getString(planSync.packageName);
33
+ if (!packageName) {
34
+ throw new ValidationError("Google Play subscription verification requires packageName in the method input or plugin config.planSync.packageName.");
35
+ }
36
+ return packageName;
37
+ }
38
+ function resolveServiceAccount(input, config) {
39
+ const planSync = asObject(config.planSync);
40
+ const googlePlay = asObject(config.googlePlay);
41
+ const serviceAccount = input.serviceAccount ??
42
+ readGoogleServiceAccount(googlePlay.serviceAccount) ??
43
+ readGoogleServiceAccount(planSync.serviceAccount);
44
+ if (!serviceAccount) {
45
+ throw new ValidationError("Google Play subscription verification requires serviceAccount credentials in the method input or plugin config.planSync.serviceAccount.");
46
+ }
47
+ return serviceAccount;
48
+ }
49
+ async function parseGooglePlayRecord(body) {
50
+ const parsed = await googlePlayPlugin.parseWebhook?.({
51
+ body,
52
+ headers: {},
53
+ receivedAt: new Date().toISOString(),
54
+ });
55
+ const [event] = Array.isArray(parsed) ? parsed : [parsed];
56
+ const record = event?.records[0];
57
+ if (!record) {
58
+ throw new Error("Google Play verification did not produce a canonical subscription record.");
59
+ }
60
+ return record;
61
+ }
62
+ async function loadGooglePlaySubscription(input, config) {
63
+ const packageName = resolvePackageName(input, config);
64
+ const serviceAccount = resolveServiceAccount(input, config);
65
+ const accessToken = await getGoogleAccessToken(serviceAccount);
66
+ const url = new URL(`https://androidpublisher.googleapis.com/androidpublisher/v3/applications/${encodeURIComponent(packageName)}/purchases/subscriptionsv2/tokens/${encodeURIComponent(input.purchaseToken)}`);
67
+ const response = await fetch(url, {
68
+ headers: {
69
+ authorization: `Bearer ${accessToken}`,
70
+ },
71
+ });
72
+ if (!response.ok) {
73
+ throw new ValidationError(`Google Play subscription lookup failed for purchase token ${input.purchaseToken} with status ${response.status}.`);
74
+ }
75
+ return asObject(await response.json());
76
+ }
77
+ export async function verifyGooglePlaySubscription(input, config = {}) {
78
+ const purchase = await loadGooglePlaySubscription(input, config);
79
+ const raw = {
80
+ eventKey: `google-play.verify:${input.purchaseToken}`,
81
+ eventType: "google-play.subscription.verified",
82
+ purchaseToken: input.purchaseToken,
83
+ subjectId: input.subjectId,
84
+ planCode: input.planCode,
85
+ subscriptionPurchaseV2: purchase,
86
+ };
87
+ const canonical = await parseGooglePlayRecord(raw);
88
+ return {
89
+ provider: "google-play",
90
+ sourceRef: canonical.sourceRef,
91
+ status: canonical.status,
92
+ canonical,
93
+ raw: purchase,
94
+ };
95
+ }
96
+ //# sourceMappingURL=play-subscription-verification-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"play-subscription-verification-service.js","sourceRoot":"","sources":["../../../../src/providers/google/services/play-subscription-verification-service.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAChE,CAAC,CAAE,KAAiC;QACpC,CAAC,CAAC,EAAE,CAAC;AACT,CAAC;AAED,SAAS,SAAS,CAAC,KAAc;IAC/B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AAC3E,CAAC;AAED,SAAS,wBAAwB,CAAC,KAAc;IAC9C,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC/B,MAAM,WAAW,GAAG,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAClD,MAAM,UAAU,GAAG,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAChD,IAAI,CAAC,WAAW,IAAI,CAAC,UAAU,EAAE,CAAC;QAChC,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO;QACL,WAAW;QACX,UAAU;QACV,YAAY,EAAE,SAAS,CAAC,MAAM,CAAC,YAAY,CAAC;QAC5C,QAAQ,EAAE,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC;QACpC,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC;KAC/B,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB,CACzB,KAAwC,EACxC,MAA+B;IAE/B,MAAM,QAAQ,GA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E,KAAK,CAAC,SAAS;QAC1B,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,sBAAsB,EAAE,QAAQ;KACC,CAAC;IACpC,MAAM,SAAS,GAAG,MAAM,qBAAqB,CAAC,GAAG,CAAC,CAAC;IAEnD,OAAO;QACL,QAAQ,EAAE,aAAa;QACvB,SAAS,EAAE,SAAS,CAAC,SAAS;QAC9B,MAAM,EAAE,SAAS,CAAC,MAAM;QACxB,SAAS;QACT,GAAG,EAAE,QAAQ;KACd,CAAC;AACJ,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { CatalogMapping } from "@shdan/submesh-core";
2
+ import type { UpsertCatalogMappingInput } from "../contracts.js";
3
+ export interface CatalogMappingRepository {
4
+ list(): Promise<CatalogMapping[]> | CatalogMapping[];
5
+ findByExternalProduct(pluginKey: string, externalProductId: string): Promise<CatalogMapping | undefined> | CatalogMapping | undefined;
6
+ upsert(input: UpsertCatalogMappingInput): Promise<CatalogMapping> | CatalogMapping;
7
+ delete(pluginKey: string, externalProductId: string): Promise<boolean> | boolean;
8
+ }
9
+ //# sourceMappingURL=catalog-mapping-repository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog-mapping-repository.d.ts","sourceRoot":"","sources":["../../src/repositories/catalog-mapping-repository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAEjE,MAAM,WAAW,wBAAwB;IACvC,IAAI,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC,GAAG,cAAc,EAAE,CAAC;IACrD,qBAAqB,CACnB,SAAS,EAAE,MAAM,EACjB,iBAAiB,EAAE,MAAM,GACxB,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,GAAG,cAAc,GAAG,SAAS,CAAC;IACpE,MAAM,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,cAAc,CAAC,GAAG,cAAc,CAAC;IACnF,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;CAClF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=catalog-mapping-repository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog-mapping-repository.js","sourceRoot":"","sources":["../../src/repositories/catalog-mapping-repository.ts"],"names":[],"mappings":""}
@@ -0,0 +1,23 @@
1
+ import type { InboundEvent, InboundEventStatus } from "@shdan/submesh-core";
2
+ export interface CreateInboundEventInput {
3
+ pluginKey: string;
4
+ eventKey: string;
5
+ eventType: string;
6
+ sourceRef?: string | null;
7
+ payload: Record<string, unknown>;
8
+ }
9
+ export interface MarkReceivedResult {
10
+ event: InboundEvent;
11
+ claimed: boolean;
12
+ }
13
+ export interface InboundEventRepository {
14
+ list(limit?: number): Promise<InboundEvent[]> | InboundEvent[];
15
+ listByStatus(status: InboundEventStatus, limit?: number): Promise<InboundEvent[]> | InboundEvent[];
16
+ getById(id: string): Promise<InboundEvent | undefined> | InboundEvent | undefined;
17
+ getByEventKey(pluginKey: string, eventKey: string): Promise<InboundEvent | undefined> | InboundEvent | undefined;
18
+ markReceived(input: CreateInboundEventInput): Promise<MarkReceivedResult> | MarkReceivedResult;
19
+ markProcessed(id: string, processedCount: number): Promise<InboundEvent> | InboundEvent;
20
+ markIgnored(id: string): Promise<InboundEvent> | InboundEvent;
21
+ markFailed(id: string, errorMessage: string): Promise<InboundEvent> | InboundEvent;
22
+ }
23
+ //# sourceMappingURL=inbound-event-repository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inbound-event-repository.d.ts","sourceRoot":"","sources":["../../src/repositories/inbound-event-repository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE5E,MAAM,WAAW,uBAAuB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//# sourceMappingURL=inbound-event-repository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inbound-event-repository.js","sourceRoot":"","sources":["../../src/repositories/inbound-event-repository.ts"],"names":[],"mappings":""}
@@ -0,0 +1,30 @@
1
+ import type { DashboardSummary } from "@shdan/submesh-core";
2
+ import type { CatalogMappingRepository } from "./catalog-mapping-repository.js";
3
+ import type { InboundEventRepository } from "./inbound-event-repository.js";
4
+ import type { PlanRepository } from "./plan-repository.js";
5
+ import type { PluginInstallationRepository } from "./plugin-installation-repository.js";
6
+ import type { SubjectRepository } from "./subject-repository.js";
7
+ import type { SubscriptionRepository } from "./subscription-repository.js";
8
+ export interface SummaryRepository {
9
+ getSummary(): Promise<DashboardSummary> | DashboardSummary;
10
+ }
11
+ export interface RepositorySet {
12
+ subjects: SubjectRepository;
13
+ plans: PlanRepository;
14
+ catalogMappings: CatalogMappingRepository;
15
+ subscriptions: SubscriptionRepository;
16
+ pluginInstallations: PluginInstallationRepository;
17
+ inboundEvents: InboundEventRepository;
18
+ summary: SummaryRepository;
19
+ }
20
+ export interface SubmeshRepositories extends RepositorySet {
21
+ transaction<T>(operation: (repositories: RepositorySet) => Promise<T> | T): Promise<T>;
22
+ close?(): Promise<void> | void;
23
+ }
24
+ export type { CatalogMappingRepository } from "./catalog-mapping-repository.js";
25
+ export type { CreateInboundEventInput, InboundEventRepository, } from "./inbound-event-repository.js";
26
+ export type { PlanRepository } from "./plan-repository.js";
27
+ export type { PluginInstallationRepository, UpsertPluginInstallationInput, } from "./plugin-installation-repository.js";
28
+ export type { SubjectRepository } from "./subject-repository.js";
29
+ export type { SubscriptionRepository, UpsertSubscriptionInput, } from "./subscription-repository.js";
30
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/repositories/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO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MAAM,yBAAyB,CAAC;AACjE,YAAY,EACV,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,8BAA8B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/repositories/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ import type { Plan } from "@shdan/submesh-core";
2
+ import type { CreatePlanInput, UpdatePlanInput } from "../contracts.js";
3
+ export interface PlanRepository {
4
+ list(): Promise<Plan[]> | Plan[];
5
+ getByCode(code: string): Promise<Plan | undefined> | Plan | undefined;
6
+ create(input: CreatePlanInput): Promise<Plan> | Plan;
7
+ update(code: string, input: UpdatePlanInput): Promise<Plan | undefined> | Plan | undefined;
8
+ delete(code: string): Promise<boolean> | boolean;
9
+ }
10
+ //# sourceMappingURL=plan-repository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan-repository.d.ts","sourceRoot":"","sources":["../../src/repositories/plan-repository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAEhD,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAExE,MAAM,WAAW,cAAc;IAC7B,IAAI,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC;IACjC,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;IACtE,MAAM,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACrD,MAAM,CACJ,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,eAAe,GACrB,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;IAChD,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;CAClD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=plan-repository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan-repository.js","sourceRoot":"","sources":["../../src/repositories/plan-repository.ts"],"names":[],"mappings":""}
@@ -0,0 +1,13 @@
1
+ import type { PluginInstallation } from "@shdan/submesh-core";
2
+ export interface UpsertPluginInstallationInput {
3
+ pluginKey: string;
4
+ displayName: string;
5
+ enabled: boolean;
6
+ config?: Record<string, unknown>;
7
+ }
8
+ export interface PluginInstallationRepository {
9
+ list(): Promise<PluginInstallation[]> | PluginInstallation[];
10
+ upsert(input: UpsertPluginInstallationInput): Promise<PluginInstallation> | PluginInstallation;
11
+ delete(pluginKey: string): Promise<boolean> | boolean;
12
+ }
13
+ //# sourceMappingURL=plugin-installation-repository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-installation-repository.d.ts","sourceRoot":"","sources":["../../src/repositories/plugin-installation-repository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,MAAM,WAAW,6BAA6B;IAC5C,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,4BAA4B;IAC3C,IAAI,IAAI,OAAO,CAAC,kBAAkB,EAAE,CAAC,GAAG,kBAAkB,EAAE,CAAC;IAC7D,MAAM,CACJ,KAAK,EAAE,6BAA6B,GACnC,OAAO,CAAC,kBAAkB,CAAC,GAAG,kBAAkB,CAAC;IACpD,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;CACvD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=plugin-installation-repository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-installation-repository.js","sourceRoot":"","sources":["../../src/repositories/plugin-installation-repository.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ import type { Subject, SubjectIdentity } from "@shdan/submesh-core";
2
+ import type { LinkIdentityInput, UpsertSubjectInput } from "../contracts.js";
3
+ export interface SubjectRepository {
4
+ list(): Promise<Subject[]> | Subject[];
5
+ getById(id: string): Promise<Subject | undefined> | Subject | undefined;
6
+ upsert(input: UpsertSubjectInput): Promise<Subject> | Subject;
7
+ findIdentity(provider: string, externalId: string): Promise<SubjectIdentity | undefined> | SubjectIdentity | undefined;
8
+ upsertIdentity(input: LinkIdentityInput): Promise<SubjectIdentity> | SubjectIdentity;
9
+ }
10
+ //# sourceMappingURL=subject-repository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subject-repository.d.ts","sourceRoot":"","sources":["../../src/repositories/subject-repository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE7E,MAAM,WAAW,iBAAiB;IAChC,IAAI,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC,GAAG,OAAO,EAAE,CAAC;IACvC,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,GAAG,OAAO,GAAG,SAAS,CAAC;IACxE,MAAM,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IAC9D,YAAY,CACV,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,GAAG,eAAe,GAAG,SAAS,CAAC;IACtE,cAAc,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,CAAC;CACtF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=subject-repository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subject-repository.js","sourceRoot":"","sources":["../../src/repositories/subject-repository.ts"],"names":[],"mappings":""}
@@ -0,0 +1,24 @@
1
+ import type { Subscription, SubscriptionStatus, SubscriptionWithPlan } from "@shdan/submesh-core";
2
+ import { UpdateSubscriptionInput } from "../contracts.js";
3
+ export interface UpsertSubscriptionInput {
4
+ subjectId: string;
5
+ planId: string;
6
+ pluginKey: string;
7
+ sourceType: string;
8
+ sourceRef: string;
9
+ status: SubscriptionStatus;
10
+ currentPeriodStart?: string | null;
11
+ currentPeriodEnd?: string | null;
12
+ trialEndAt?: string | null;
13
+ cancelAt?: string | null;
14
+ metadata?: Record<string, unknown>;
15
+ }
16
+ export interface SubscriptionRepository {
17
+ list(): Promise<SubscriptionWithPlan[]> | SubscriptionWithPlan[];
18
+ listBySubjectId(subjectId: string): Promise<SubscriptionWithPlan[]> | SubscriptionWithPlan[];
19
+ getById(id: string): Promise<SubscriptionWithPlan | undefined> | SubscriptionWithPlan | undefined;
20
+ getBySource(pluginKey: string, sourceRef: string): Promise<Subscription | undefined> | Subscription | undefined;
21
+ upsert(input: UpsertSubscriptionInput): Promise<Subscription> | Subscription;
22
+ update(id: string, input: UpdateSubscriptionInput): Promise<Subscription | undefined> | Subscription | undefined;
23
+ }
24
+ //# sourceMappingURL=subscription-repository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscription-repository.d.ts","sourceRoot":"","sources":["../../src/repositories/subscription-repository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,oBAAoB,EACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB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0,0 +1 @@
1
+ {"version":3,"file":"subscription-repository.js","sourceRoot":"","sources":["../../src/repositories/subscription-repository.ts"],"names":[],"mappings":""}
@@ -0,0 +1,22 @@
1
+ import { type KeyObject } from "node:crypto";
2
+ type SupportedJwtAlgorithm = "ES256" | "RS256";
3
+ export interface ParsedSignedToken<TPayload extends Record<string, unknown> = Record<string, unknown>> {
4
+ header: Record<string, unknown>;
5
+ payload: TPayload;
6
+ signingInput: string;
7
+ signature: Buffer;
8
+ }
9
+ export declare function parseSignedToken<TPayload extends Record<string, unknown> = Record<string, unknown>>(token: string): ParsedSignedToken<TPayload>;
10
+ export declare function decodeSignedPayload<TPayload extends Record<string, unknown> = Record<string, unknown>>(token: string): TPayload;
11
+ export declare function verifySignedTokenSignature(input: {
12
+ token: string;
13
+ algorithm: SupportedJwtAlgorithm;
14
+ publicKeys: Array<string | KeyObject>;
15
+ }): ParsedSignedToken;
16
+ export declare function resolveX5cLeafPublicKeys(input: {
17
+ x5c: unknown;
18
+ trustedRootCertificates: string[];
19
+ now?: Date;
20
+ }): KeyObject[];
21
+ export {};
22
+ //# sourceMappingURL=jwt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jwt.d.ts","sourceRoot":"","sources":["../../src/security/jwt.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,SAAS,EAEf,MAAM,aAAa,CAAC;AAErB,KAAK,qBAAqB,GAAG,OAAO,GAAG,OAAO,CAAC;AAE/C,MAAM,WAAW,iBAAiB,CAChC,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAElE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,OAAO,EAAE,QAAQ,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB;AAgFD,wBAAgB,gBAAgB,CAC9B,QAAQ,SAAS,MAA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