@churchapps/content-providers 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -97,6 +97,7 @@ var TokenHelper = class {
97
97
  refresh_token: auth.refresh_token,
98
98
  client_id: config.clientId
99
99
  });
100
+ if (config.clientSecret) params.set("client_secret", config.clientSecret);
100
101
  const response = await fetch(`${config.oauthBase}/token`, { method: "POST", headers: { "Content-Type": "application/x-www-form-urlencoded" }, body: params.toString() });
101
102
  if (!response.ok) {
102
103
  console.warn(`[TokenHelper] Token refresh failed: ${response.status} ${response.statusText}`);
@@ -166,6 +167,7 @@ var OAuthHelper = class {
166
167
  client_id: config.clientId,
167
168
  code_verifier: codeVerifier
168
169
  });
170
+ if (config.clientSecret) params.set("client_secret", config.clientSecret);
169
171
  const tokenUrl = `${config.oauthBase}/token`;
170
172
  const response = await fetch(tokenUrl, { method: "POST", headers: { "Content-Type": "application/x-www-form-urlencoded" }, body: params.toString() });
171
173
  if (!response.ok) {
@@ -983,18 +985,6 @@ var LessonsChurchProvider = class extends BaseProvider {
983
985
  }
984
986
  };
985
987
 
986
- // src/providers/registry.ts
987
- var providerRegistry = /* @__PURE__ */ new Map();
988
- function getProvider(providerId) {
989
- return providerRegistry.get(providerId) || null;
990
- }
991
- function getAllProviders() {
992
- return Array.from(providerRegistry.values());
993
- }
994
- function registerProvider(provider) {
995
- providerRegistry.set(provider.id, provider);
996
- }
997
-
998
988
  // src/providers/b1Church/B1ChurchAuth.ts
999
989
  function buildB1AuthUrlFromChallenge(config, appBase, redirectUri, codeChallenge, state) {
1000
990
  const oauthParams = new URLSearchParams({
@@ -1453,14 +1443,12 @@ var B1ChurchProvider = class extends BaseProvider {
1453
1443
  this.planTypeId = null;
1454
1444
  }
1455
1445
  }
1456
- async getCurrentPlan(_authData) {
1446
+ async getCurrentPlan(authData) {
1457
1447
  if (!this.planTypeId) return null;
1458
1448
  const plan = await fetchCurrentPlanByType(this.planTypeId);
1459
- if (!plan?.providerId || !plan.providerPlanId) return null;
1449
+ if (!plan?.providerId || !plan.providerPlanId || !plan.ministryId) return null;
1460
1450
  const items = plan.churchId && plan.id ? await fetchPlanItems(plan.churchId, plan.id) : [];
1461
- const innerProvider = getProvider(plan.providerId);
1462
- if (!innerProvider?.getInstructions) return null;
1463
- const instructions = await innerProvider.getInstructions(plan.providerPlanId, null);
1451
+ const instructions = await fetchFromProviderProxy("getInstructions", plan.ministryId, plan.providerId, plan.providerPlanId, authData);
1464
1452
  if (!instructions) return null;
1465
1453
  const files = getOrderedFiles(instructions, items);
1466
1454
  const thumbnail = findFirstThumbnail(instructions.items);
@@ -16303,6 +16291,110 @@ var LifeChurchProvider = class extends BaseProvider {
16303
16291
  }
16304
16292
  };
16305
16293
 
16294
+ // src/providers/registry.ts
16295
+ var providerRegistry = /* @__PURE__ */ new Map();
16296
+ function getProvider(providerId) {
16297
+ return providerRegistry.get(providerId) || null;
16298
+ }
16299
+ function getAllProviders() {
16300
+ return Array.from(providerRegistry.values());
16301
+ }
16302
+ function registerProvider(provider) {
16303
+ providerRegistry.set(provider.id, provider);
16304
+ }
16305
+
16306
+ // src/providers/goCurriculum/data.json
16307
+ var data_default4 = {
16308
+ collections: []
16309
+ };
16310
+
16311
+ // src/providers/goCurriculum/GoCurriculumProvider.ts
16312
+ var GoCurriculumProvider = class extends BaseProvider {
16313
+ constructor() {
16314
+ super(...arguments);
16315
+ this.oauthHelper = new OAuthHelper();
16316
+ this.verifiedTokens = /* @__PURE__ */ new Set();
16317
+ this.id = "gocurriculum";
16318
+ this.name = "Go Curriculum";
16319
+ this.logos = {
16320
+ light: "https://gocurriculum.com/wp-content/uploads/go-logo-curriculum-v2.png",
16321
+ dark: "https://gocurriculum.com/wp-content/uploads/go-logo-curriculum-v2.png"
16322
+ };
16323
+ this.config = {
16324
+ id: "gocurriculum",
16325
+ name: "Go Curriculum",
16326
+ apiBase: "https://gocurriculum.com",
16327
+ oauthBase: "https://gocurriculum.com/oauth",
16328
+ clientId: "Rdrvz9jz9nTNf8rCsbpuAgVLdoWHZmcjdmmrP0Bw",
16329
+ clientSecret: "yfAbd2NERjzwVZP38g1AALdIvPPXwhFayCguiTCS",
16330
+ scopes: ["basic"]
16331
+ };
16332
+ this.data = data_default4;
16333
+ this.requiresAuth = true;
16334
+ this.authTypes = ["oauth_pkce"];
16335
+ this.capabilities = { browse: true, playlist: true, instructions: true, mediaLicensing: false };
16336
+ }
16337
+ // ponytail: any valid login unlocks everything for the pilot — per-tier (MemberPress) filtering waits on Go's membership endpoint
16338
+ async verifyAuth(auth) {
16339
+ const token = auth?.access_token;
16340
+ if (!token) return false;
16341
+ if (this.verifiedTokens.has(token)) return true;
16342
+ try {
16343
+ const response = await fetch(`${this.config.oauthBase}/me`, { method: "POST", headers: { "Content-Type": "application/x-www-form-urlencoded" }, body: new URLSearchParams({ access_token: token }).toString() });
16344
+ if (!response.ok) return false;
16345
+ this.verifiedTokens.add(token);
16346
+ return true;
16347
+ } catch {
16348
+ return false;
16349
+ }
16350
+ }
16351
+ async browse(path, auth) {
16352
+ if (!await this.verifyAuth(auth)) return [];
16353
+ const { segments, depth } = parsePath(path);
16354
+ if (depth === 0) return this.data.collections.map((c) => createFolder(c.id, c.name, `/${c.id}`, c.image));
16355
+ const collection = this.data.collections.find((c) => c.id === segments[0]);
16356
+ if (!collection) return [];
16357
+ if (depth === 1) return collection.lessons.map((l) => createFolder(l.id, l.name, `/${collection.id}/${l.id}`, l.image || collection.image, true));
16358
+ if (depth === 2) return this.getLessonFiles(collection, segments[1]);
16359
+ return [];
16360
+ }
16361
+ getLessonFiles(collection, lessonId) {
16362
+ const lesson = collection.lessons.find((l) => l.id === lessonId);
16363
+ if (!lesson) return [];
16364
+ return lesson.files.map((f) => createFile(f.id, f.name, f.url, { mediaType: detectMediaType(`${f.url} ${f.name}`, f.fileType), thumbnail: f.thumbnail || lesson.image || collection.image, seconds: f.seconds, loop: f.loop, loopVideo: f.loopVideo }));
16365
+ }
16366
+ async getPlaylist(path, auth, _resolution) {
16367
+ if (!await this.verifyAuth(auth)) return null;
16368
+ const { segments, depth } = parsePath(path);
16369
+ if (depth !== 2) return null;
16370
+ const collection = this.data.collections.find((c) => c.id === segments[0]);
16371
+ if (!collection) return null;
16372
+ const files = this.getLessonFiles(collection, segments[1]);
16373
+ return files.length > 0 ? files : null;
16374
+ }
16375
+ async getInstructions(path, auth) {
16376
+ const { segments, depth } = parsePath(path);
16377
+ if (depth !== 2) return null;
16378
+ const files = await this.getPlaylist(path, auth);
16379
+ if (!files) return null;
16380
+ const collection = this.data.collections.find((c) => c.id === segments[0]);
16381
+ const lesson = collection?.lessons.find((l) => l.id === segments[1]);
16382
+ return filesToInstructions(lesson?.name || "Lesson", files);
16383
+ }
16384
+ generateCodeVerifier() {
16385
+ return this.oauthHelper.generateCodeVerifier();
16386
+ }
16387
+ async buildAuthUrl(codeVerifier, redirectUri, state) {
16388
+ return this.oauthHelper.buildAuthUrl(this.config, codeVerifier, redirectUri, state || this.id);
16389
+ }
16390
+ buildAuthUrlFromChallenge(codeChallenge, redirectUri, state) {
16391
+ return this.oauthHelper.buildAuthUrlFromChallenge(this.config, codeChallenge, redirectUri, state);
16392
+ }
16393
+ async exchangeCodeForTokens(code, codeVerifier, redirectUri) {
16394
+ return this.oauthHelper.exchangeCodeForTokens(this.config, this.id, code, codeVerifier, redirectUri);
16395
+ }
16396
+ };
16397
+
16306
16398
  // src/providers/index.ts
16307
16399
  var unimplementedProviders = [
16308
16400
  {
@@ -16321,14 +16413,6 @@ var unimplementedProviders = [
16321
16413
  dark: "https://freeshow.app/images/favicon.png"
16322
16414
  }
16323
16415
  },
16324
- {
16325
- id: "gocurriculum",
16326
- name: "Go Curriculum",
16327
- logos: {
16328
- light: "https://gocurriculum.com/wp-content/uploads/go-logo-curriculum-v2.png",
16329
- dark: "https://gocurriculum.com/wp-content/uploads/go-logo-curriculum-v2.png"
16330
- }
16331
- },
16332
16416
  {
16333
16417
  id: "iteachchurch",
16334
16418
  name: "iTeachChurch",
@@ -16351,6 +16435,7 @@ function initializeProviders() {
16351
16435
  new APlayProvider(),
16352
16436
  new B1ChurchProvider(),
16353
16437
  new DropboxProvider(),
16438
+ new GoCurriculumProvider(),
16354
16439
  new BibleProjectProvider(),
16355
16440
  new HighVoltageKidsProvider(),
16356
16441
  new JesusFilmProvider(),
@@ -16395,7 +16480,7 @@ function getAvailableProviders(ids) {
16395
16480
  }
16396
16481
 
16397
16482
  // src/index.ts
16398
- var VERSION = true ? "0.6.0" : "dev";
16483
+ var VERSION = true ? "0.6.1" : "dev";
16399
16484
  // Annotate the CommonJS export names for ESM import in node:
16400
16485
  0 && (module.exports = {
16401
16486
  APlayProvider,