@churchapps/content-providers 0.6.0 → 0.7.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.
- package/dist/index.cjs +123 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +122 -26
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -44,6 +44,7 @@ __export(index_exports, {
|
|
|
44
44
|
isContentFolder: () => isContentFolder,
|
|
45
45
|
navigateToPath: () => navigateToPath,
|
|
46
46
|
registerProvider: () => registerProvider,
|
|
47
|
+
setProviderSecret: () => setProviderSecret,
|
|
47
48
|
toAuthData: () => toAuthData
|
|
48
49
|
});
|
|
49
50
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -97,6 +98,7 @@ var TokenHelper = class {
|
|
|
97
98
|
refresh_token: auth.refresh_token,
|
|
98
99
|
client_id: config.clientId
|
|
99
100
|
});
|
|
101
|
+
if (config.clientSecret) params.set("client_secret", config.clientSecret);
|
|
100
102
|
const response = await fetch(`${config.oauthBase}/token`, { method: "POST", headers: { "Content-Type": "application/x-www-form-urlencoded" }, body: params.toString() });
|
|
101
103
|
if (!response.ok) {
|
|
102
104
|
console.warn(`[TokenHelper] Token refresh failed: ${response.status} ${response.statusText}`);
|
|
@@ -166,6 +168,7 @@ var OAuthHelper = class {
|
|
|
166
168
|
client_id: config.clientId,
|
|
167
169
|
code_verifier: codeVerifier
|
|
168
170
|
});
|
|
171
|
+
if (config.clientSecret) params.set("client_secret", config.clientSecret);
|
|
169
172
|
const tokenUrl = `${config.oauthBase}/token`;
|
|
170
173
|
const response = await fetch(tokenUrl, { method: "POST", headers: { "Content-Type": "application/x-www-form-urlencoded" }, body: params.toString() });
|
|
171
174
|
if (!response.ok) {
|
|
@@ -249,6 +252,13 @@ var ApiHelper = class {
|
|
|
249
252
|
}
|
|
250
253
|
};
|
|
251
254
|
|
|
255
|
+
// src/helpers/ProviderSecrets.ts
|
|
256
|
+
var secrets = {};
|
|
257
|
+
var setProviderSecret = (providerId, secret) => {
|
|
258
|
+
secrets[providerId] = secret;
|
|
259
|
+
};
|
|
260
|
+
var getProviderSecret = (providerId) => secrets[providerId] || "";
|
|
261
|
+
|
|
252
262
|
// src/providers/BaseProvider.ts
|
|
253
263
|
var BaseProvider = class {
|
|
254
264
|
constructor() {
|
|
@@ -983,18 +993,6 @@ var LessonsChurchProvider = class extends BaseProvider {
|
|
|
983
993
|
}
|
|
984
994
|
};
|
|
985
995
|
|
|
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
996
|
// src/providers/b1Church/B1ChurchAuth.ts
|
|
999
997
|
function buildB1AuthUrlFromChallenge(config, appBase, redirectUri, codeChallenge, state) {
|
|
1000
998
|
const oauthParams = new URLSearchParams({
|
|
@@ -1453,14 +1451,12 @@ var B1ChurchProvider = class extends BaseProvider {
|
|
|
1453
1451
|
this.planTypeId = null;
|
|
1454
1452
|
}
|
|
1455
1453
|
}
|
|
1456
|
-
async getCurrentPlan(
|
|
1454
|
+
async getCurrentPlan(authData) {
|
|
1457
1455
|
if (!this.planTypeId) return null;
|
|
1458
1456
|
const plan = await fetchCurrentPlanByType(this.planTypeId);
|
|
1459
|
-
if (!plan?.providerId || !plan.providerPlanId) return null;
|
|
1457
|
+
if (!plan?.providerId || !plan.providerPlanId || !plan.ministryId) return null;
|
|
1460
1458
|
const items = plan.churchId && plan.id ? await fetchPlanItems(plan.churchId, plan.id) : [];
|
|
1461
|
-
const
|
|
1462
|
-
if (!innerProvider?.getInstructions) return null;
|
|
1463
|
-
const instructions = await innerProvider.getInstructions(plan.providerPlanId, null);
|
|
1459
|
+
const instructions = await fetchFromProviderProxy("getInstructions", plan.ministryId, plan.providerId, plan.providerPlanId, authData);
|
|
1464
1460
|
if (!instructions) return null;
|
|
1465
1461
|
const files = getOrderedFiles(instructions, items);
|
|
1466
1462
|
const thumbnail = findFirstThumbnail(instructions.items);
|
|
@@ -16303,6 +16299,113 @@ var LifeChurchProvider = class extends BaseProvider {
|
|
|
16303
16299
|
}
|
|
16304
16300
|
};
|
|
16305
16301
|
|
|
16302
|
+
// src/providers/registry.ts
|
|
16303
|
+
var providerRegistry = /* @__PURE__ */ new Map();
|
|
16304
|
+
function getProvider(providerId) {
|
|
16305
|
+
return providerRegistry.get(providerId) || null;
|
|
16306
|
+
}
|
|
16307
|
+
function getAllProviders() {
|
|
16308
|
+
return Array.from(providerRegistry.values());
|
|
16309
|
+
}
|
|
16310
|
+
function registerProvider(provider) {
|
|
16311
|
+
providerRegistry.set(provider.id, provider);
|
|
16312
|
+
}
|
|
16313
|
+
|
|
16314
|
+
// src/providers/goCurriculum/data.json
|
|
16315
|
+
var data_default4 = {
|
|
16316
|
+
catalog: []
|
|
16317
|
+
};
|
|
16318
|
+
|
|
16319
|
+
// src/providers/goCurriculum/GoCurriculumProvider.ts
|
|
16320
|
+
var GoCurriculumProvider = class extends BaseProvider {
|
|
16321
|
+
constructor() {
|
|
16322
|
+
super(...arguments);
|
|
16323
|
+
this.oauthHelper = new OAuthHelper();
|
|
16324
|
+
this.verifiedTokens = /* @__PURE__ */ new Set();
|
|
16325
|
+
this.id = "gocurriculum";
|
|
16326
|
+
this.name = "Go Curriculum";
|
|
16327
|
+
this.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
|
+
this.config = {
|
|
16332
|
+
id: "gocurriculum",
|
|
16333
|
+
name: "Go Curriculum",
|
|
16334
|
+
apiBase: "https://gocurriculum.com",
|
|
16335
|
+
oauthBase: "https://gocurriculum.com/oauth",
|
|
16336
|
+
clientId: "Rdrvz9jz9nTNf8rCsbpuAgVLdoWHZmcjdmmrP0Bw",
|
|
16337
|
+
// supplied at runtime via setProviderSecret("gocurriculum", ...) — never commit the value
|
|
16338
|
+
get clientSecret() {
|
|
16339
|
+
return getProviderSecret("gocurriculum");
|
|
16340
|
+
},
|
|
16341
|
+
scopes: ["basic"]
|
|
16342
|
+
};
|
|
16343
|
+
this.data = data_default4;
|
|
16344
|
+
this.requiresAuth = true;
|
|
16345
|
+
this.authTypes = ["oauth_pkce"];
|
|
16346
|
+
this.capabilities = { browse: true, playlist: true, instructions: true, mediaLicensing: false };
|
|
16347
|
+
}
|
|
16348
|
+
// ponytail: any valid login unlocks everything for the pilot — per-tier (MemberPress) filtering waits on Go's membership endpoint
|
|
16349
|
+
async verifyAuth(auth) {
|
|
16350
|
+
const token = auth?.access_token;
|
|
16351
|
+
if (!token) return false;
|
|
16352
|
+
if (this.verifiedTokens.has(token)) return true;
|
|
16353
|
+
try {
|
|
16354
|
+
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() });
|
|
16355
|
+
if (!response.ok) return false;
|
|
16356
|
+
this.verifiedTokens.add(token);
|
|
16357
|
+
return true;
|
|
16358
|
+
} catch {
|
|
16359
|
+
return false;
|
|
16360
|
+
}
|
|
16361
|
+
}
|
|
16362
|
+
async browse(path, auth) {
|
|
16363
|
+
if (!await this.verifyAuth(auth)) return [];
|
|
16364
|
+
const { segments, depth } = parsePath(path);
|
|
16365
|
+
if (depth === 0) return this.data.catalog.map((c) => createFolder(c.id, c.name, `/${c.id}`, c.thumbnail));
|
|
16366
|
+
const collection = this.data.catalog.find((c) => c.id === segments[0]);
|
|
16367
|
+
if (!collection) return [];
|
|
16368
|
+
if (depth === 1) return collection.lessons.map((l) => createFolder(l.id, l.name, `/${collection.id}/${l.id}`, l.thumbnail || collection.thumbnail, true));
|
|
16369
|
+
if (depth === 2) return this.getLessonFiles(collection, segments[1]);
|
|
16370
|
+
return [];
|
|
16371
|
+
}
|
|
16372
|
+
getLessonFiles(collection, lessonId) {
|
|
16373
|
+
const lesson = collection.lessons.find((l) => l.id === lessonId);
|
|
16374
|
+
if (!lesson) return [];
|
|
16375
|
+
return lesson.playlist.map((f) => createFile(slugify(f.file), f.title, f.url, { mediaType: detectMediaType(`${f.url} ${f.file}`, f.mediaType), thumbnail: f.thumbnail || lesson.thumbnail || collection.thumbnail, seconds: f.duration }));
|
|
16376
|
+
}
|
|
16377
|
+
async getPlaylist(path, auth, _resolution) {
|
|
16378
|
+
if (!await this.verifyAuth(auth)) return null;
|
|
16379
|
+
const { segments, depth } = parsePath(path);
|
|
16380
|
+
if (depth !== 2) return null;
|
|
16381
|
+
const collection = this.data.catalog.find((c) => c.id === segments[0]);
|
|
16382
|
+
if (!collection) return null;
|
|
16383
|
+
const files = this.getLessonFiles(collection, segments[1]);
|
|
16384
|
+
return files.length > 0 ? files : null;
|
|
16385
|
+
}
|
|
16386
|
+
async getInstructions(path, auth) {
|
|
16387
|
+
const { segments, depth } = parsePath(path);
|
|
16388
|
+
if (depth !== 2) return null;
|
|
16389
|
+
const files = await this.getPlaylist(path, auth);
|
|
16390
|
+
if (!files) return null;
|
|
16391
|
+
const collection = this.data.catalog.find((c) => c.id === segments[0]);
|
|
16392
|
+
const lesson = collection?.lessons.find((l) => l.id === segments[1]);
|
|
16393
|
+
return filesToInstructions(lesson?.name || "Lesson", files);
|
|
16394
|
+
}
|
|
16395
|
+
generateCodeVerifier() {
|
|
16396
|
+
return this.oauthHelper.generateCodeVerifier();
|
|
16397
|
+
}
|
|
16398
|
+
async buildAuthUrl(codeVerifier, redirectUri, state) {
|
|
16399
|
+
return this.oauthHelper.buildAuthUrl(this.config, codeVerifier, redirectUri, state || this.id);
|
|
16400
|
+
}
|
|
16401
|
+
buildAuthUrlFromChallenge(codeChallenge, redirectUri, state) {
|
|
16402
|
+
return this.oauthHelper.buildAuthUrlFromChallenge(this.config, codeChallenge, redirectUri, state);
|
|
16403
|
+
}
|
|
16404
|
+
async exchangeCodeForTokens(code, codeVerifier, redirectUri) {
|
|
16405
|
+
return this.oauthHelper.exchangeCodeForTokens(this.config, this.id, code, codeVerifier, redirectUri);
|
|
16406
|
+
}
|
|
16407
|
+
};
|
|
16408
|
+
|
|
16306
16409
|
// src/providers/index.ts
|
|
16307
16410
|
var unimplementedProviders = [
|
|
16308
16411
|
{
|
|
@@ -16321,14 +16424,6 @@ var unimplementedProviders = [
|
|
|
16321
16424
|
dark: "https://freeshow.app/images/favicon.png"
|
|
16322
16425
|
}
|
|
16323
16426
|
},
|
|
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
16427
|
{
|
|
16333
16428
|
id: "iteachchurch",
|
|
16334
16429
|
name: "iTeachChurch",
|
|
@@ -16351,6 +16446,7 @@ function initializeProviders() {
|
|
|
16351
16446
|
new APlayProvider(),
|
|
16352
16447
|
new B1ChurchProvider(),
|
|
16353
16448
|
new DropboxProvider(),
|
|
16449
|
+
new GoCurriculumProvider(),
|
|
16354
16450
|
new BibleProjectProvider(),
|
|
16355
16451
|
new HighVoltageKidsProvider(),
|
|
16356
16452
|
new JesusFilmProvider(),
|
|
@@ -16395,7 +16491,7 @@ function getAvailableProviders(ids) {
|
|
|
16395
16491
|
}
|
|
16396
16492
|
|
|
16397
16493
|
// src/index.ts
|
|
16398
|
-
var VERSION = true ? "0.
|
|
16494
|
+
var VERSION = true ? "0.7.0" : "dev";
|
|
16399
16495
|
// Annotate the CommonJS export names for ESM import in node:
|
|
16400
16496
|
0 && (module.exports = {
|
|
16401
16497
|
APlayProvider,
|
|
@@ -16422,6 +16518,7 @@ var VERSION = true ? "0.6.0" : "dev";
|
|
|
16422
16518
|
isContentFolder,
|
|
16423
16519
|
navigateToPath,
|
|
16424
16520
|
registerProvider,
|
|
16521
|
+
setProviderSecret,
|
|
16425
16522
|
toAuthData
|
|
16426
16523
|
});
|
|
16427
16524
|
//# sourceMappingURL=index.cjs.map
|