strapi-plugin-firebase-authentication 1.0.1 → 1.0.4
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/README.md +3 -3
- package/dist/_chunks/{App-ucyQ3wQ0.js → App-CUXkt5vK.js} +3 -3
- package/dist/_chunks/{App-CSI6Err4.mjs → App-ClT17CMm.mjs} +94 -115
- package/dist/_chunks/{api-DsC4NiMF.mjs → api-4NKlZ1KL.mjs} +1 -1
- package/dist/_chunks/{api-_NrpM6KB.js → api-BJej9FGu.js} +1 -1
- package/dist/_chunks/{index-D6wh_wve.mjs → index-B9iNgpX2.mjs} +6 -6
- package/dist/_chunks/{index-DJDpecNi.mjs → index-CfEq2YaU.mjs} +2 -2
- package/dist/_chunks/{index-BavxEoR2.js → index-DE_DEDmy.js} +6 -6
- package/dist/_chunks/{index-C4tASYZr.js → index-Tl1tZb4M.js} +2 -2
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/src/pluginId.d.ts +2 -2
- package/dist/server/index.js +49 -44
- package/dist/server/index.mjs +49 -44
- package/dist/server/src/content-types/index.d.ts +1 -1
- package/dist/server/src/firebaseAuthentication/types.d.ts +4 -0
- package/dist/server/src/index.d.ts +4 -2
- package/dist/server/src/services/firebaseService.d.ts +3 -2
- package/dist/server/src/services/index.d.ts +3 -1
- package/package.json +2 -2
- package/dist/server/src/firebaseAuth/types.d.ts +0 -4
- /package/dist/server/src/routes/{firebase-auth-configuration.d.ts → firebase-authentication-configuration.d.ts} +0 -0
- /package/dist/server/src/services/{firebase-auth-configuration.d.ts → firebase-authentication-configuration.d.ts} +0 -0
package/dist/server/index.js
CHANGED
|
@@ -33,17 +33,17 @@ const bootstrap = async ({ strapi: strapi2 }) => {
|
|
|
33
33
|
section: "plugins",
|
|
34
34
|
displayName: "Allow access to the Firebase Auth interface",
|
|
35
35
|
uid: "menu-link",
|
|
36
|
-
pluginName: "firebase-
|
|
36
|
+
pluginName: "firebase-authentication"
|
|
37
37
|
}
|
|
38
38
|
];
|
|
39
|
-
await strapi2.plugin("firebase-
|
|
39
|
+
await strapi2.plugin("firebase-authentication").service("settingsService").init();
|
|
40
40
|
await strapi2.admin.services.permission.actionProvider.registerMany(actions);
|
|
41
41
|
};
|
|
42
42
|
const destroy = ({ strapi: strapi2 }) => {
|
|
43
43
|
};
|
|
44
44
|
const register = ({ strapi: strapi2 }) => {
|
|
45
45
|
strapi2.log.info("Firebase Auth Plugin registered");
|
|
46
|
-
strapi2.config.get("plugin::firebase-
|
|
46
|
+
strapi2.config.get("plugin::firebase-authentication");
|
|
47
47
|
};
|
|
48
48
|
const config = {
|
|
49
49
|
default: ({ env: env2 }) => ({
|
|
@@ -56,11 +56,11 @@ const config = {
|
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
58
|
const kind = "singleType";
|
|
59
|
-
const collectionName = "
|
|
59
|
+
const collectionName = "firebase_authentication_configurations";
|
|
60
60
|
const info = {
|
|
61
|
-
singularName: "firebase-
|
|
62
|
-
pluralName: "firebase-
|
|
63
|
-
displayName: "Firebase-
|
|
61
|
+
singularName: "firebase-authentication-configuration",
|
|
62
|
+
pluralName: "firebase-authentication-configurations",
|
|
63
|
+
displayName: "Firebase-authentication configuration"
|
|
64
64
|
};
|
|
65
65
|
const options = {
|
|
66
66
|
draftAndPublish: false
|
|
@@ -86,8 +86,8 @@ const schema$1 = {
|
|
|
86
86
|
pluginOptions,
|
|
87
87
|
attributes
|
|
88
88
|
};
|
|
89
|
-
const contentTypes = { "firebase-
|
|
90
|
-
const pluginName = "firebase-
|
|
89
|
+
const contentTypes = { "firebase-authentication-configuration": { schema: schema$1 } };
|
|
90
|
+
const pluginName = "firebase-authentication";
|
|
91
91
|
const firebaseController = {
|
|
92
92
|
async validateToken(ctx) {
|
|
93
93
|
console.log("validateToken 🤣");
|
|
@@ -25151,33 +25151,33 @@ const userController = {
|
|
|
25151
25151
|
pagination.page = 1;
|
|
25152
25152
|
pagination.pageSize = 10;
|
|
25153
25153
|
}
|
|
25154
|
-
ctx.body = await strapi.plugin("firebase-
|
|
25154
|
+
ctx.body = await strapi.plugin("firebase-authentication").service("userService").list(pagination, nextPageToken);
|
|
25155
25155
|
},
|
|
25156
25156
|
create: async (ctx) => {
|
|
25157
|
-
ctx.body = await strapi.plugin("firebase-
|
|
25157
|
+
ctx.body = await strapi.plugin("firebase-authentication").service("userService").create(ctx.request.body);
|
|
25158
25158
|
},
|
|
25159
25159
|
get: async (ctx) => {
|
|
25160
|
-
ctx.body = await strapi.plugin("firebase-
|
|
25160
|
+
ctx.body = await strapi.plugin("firebase-authentication").service("userService").get(ctx.params.id);
|
|
25161
25161
|
},
|
|
25162
25162
|
update: async (ctx) => {
|
|
25163
|
-
ctx.body = await strapi.plugin("firebase-
|
|
25163
|
+
ctx.body = await strapi.plugin("firebase-authentication").service("userService").update(ctx.params.id, ctx.request.body);
|
|
25164
25164
|
},
|
|
25165
25165
|
delete: async (ctx) => {
|
|
25166
25166
|
const { destination } = ctx.request.query;
|
|
25167
25167
|
switch (destination) {
|
|
25168
25168
|
case STRAPI_DESTINATION:
|
|
25169
|
-
ctx.body = await strapi.plugin("firebase-
|
|
25169
|
+
ctx.body = await strapi.plugin("firebase-authentication").service("userService").deleteStrapiUser(ctx.params.id);
|
|
25170
25170
|
break;
|
|
25171
25171
|
case FIREBASE_DESTINATION:
|
|
25172
|
-
ctx.body = await strapi.plugin("firebase-
|
|
25172
|
+
ctx.body = await strapi.plugin("firebase-authentication").service("userService").deleteFirebaseUser(ctx.params.id);
|
|
25173
25173
|
break;
|
|
25174
25174
|
default:
|
|
25175
|
-
ctx.body = await strapi.plugin("firebase-
|
|
25175
|
+
ctx.body = await strapi.plugin("firebase-authentication").service("userService").delete(ctx.params.id);
|
|
25176
25176
|
break;
|
|
25177
25177
|
}
|
|
25178
25178
|
},
|
|
25179
25179
|
deleteMany: async (ctx) => {
|
|
25180
|
-
ctx.body = await strapi.plugin("firebase-
|
|
25180
|
+
ctx.body = await strapi.plugin("firebase-authentication").service("userService").deleteMany(ctx.query.ids);
|
|
25181
25181
|
},
|
|
25182
25182
|
resetPassword: async (ctx) => {
|
|
25183
25183
|
const { destination } = ctx.request.query;
|
|
@@ -25186,17 +25186,17 @@ const userController = {
|
|
|
25186
25186
|
}
|
|
25187
25187
|
switch (destination) {
|
|
25188
25188
|
case STRAPI_DESTINATION:
|
|
25189
|
-
ctx.body = await strapi.plugin("firebase-
|
|
25189
|
+
ctx.body = await strapi.plugin("firebase-authentication").service("userService").resetPasswordStrapiUser(ctx.params.id, {
|
|
25190
25190
|
password: ctx.request.body.password
|
|
25191
25191
|
});
|
|
25192
25192
|
break;
|
|
25193
25193
|
case FIREBASE_DESTINATION:
|
|
25194
|
-
ctx.body = await strapi.plugin("firebase-
|
|
25194
|
+
ctx.body = await strapi.plugin("firebase-authentication").service("userService").resetPasswordFirebaseUser(ctx.params.id, {
|
|
25195
25195
|
password: ctx.request.body.password
|
|
25196
25196
|
});
|
|
25197
25197
|
break;
|
|
25198
25198
|
default:
|
|
25199
|
-
ctx.body = await strapi.plugin("firebase-
|
|
25199
|
+
ctx.body = await strapi.plugin("firebase-authentication").service("userService").resetPassword(ctx.params.id, {
|
|
25200
25200
|
password: ctx.request.body.password
|
|
25201
25201
|
});
|
|
25202
25202
|
break;
|
|
@@ -25205,14 +25205,14 @@ const userController = {
|
|
|
25205
25205
|
};
|
|
25206
25206
|
const settingsController = {
|
|
25207
25207
|
setToken: async (ctx) => {
|
|
25208
|
-
ctx.body = await strapi.plugin("firebase-
|
|
25208
|
+
ctx.body = await strapi.plugin("firebase-authentication").service("settingsService").setToken(ctx);
|
|
25209
25209
|
},
|
|
25210
25210
|
setFirebaseConfigJson: async (ctx) => {
|
|
25211
|
-
ctx.body = await strapi.plugin("firebase-
|
|
25211
|
+
ctx.body = await strapi.plugin("firebase-authentication").service("settingsService").setFirebaseConfigJson(ctx);
|
|
25212
25212
|
},
|
|
25213
25213
|
getFirebaseConfigJson: async (ctx) => {
|
|
25214
25214
|
try {
|
|
25215
|
-
const config2 = await strapi.plugin("firebase-
|
|
25215
|
+
const config2 = await strapi.plugin("firebase-authentication").service("settingsService").getFirebaseConfigJson(ctx);
|
|
25216
25216
|
if (!config2) {
|
|
25217
25217
|
return ctx.send(null);
|
|
25218
25218
|
}
|
|
@@ -25225,7 +25225,7 @@ const settingsController = {
|
|
|
25225
25225
|
},
|
|
25226
25226
|
async delFirebaseConfigJson(ctx) {
|
|
25227
25227
|
try {
|
|
25228
|
-
const isExist = await strapi.plugin("firebase-
|
|
25228
|
+
const isExist = await strapi.plugin("firebase-authentication").service("settingsService").delFirebaseConfigJson(ctx);
|
|
25229
25229
|
if (!isExist) {
|
|
25230
25230
|
throw new errors.NotFoundError("No Firebase configs exists for deletion");
|
|
25231
25231
|
}
|
|
@@ -25239,7 +25239,7 @@ const settingsController = {
|
|
|
25239
25239
|
},
|
|
25240
25240
|
async restart(ctx) {
|
|
25241
25241
|
try {
|
|
25242
|
-
await strapi.plugin("firebase-
|
|
25242
|
+
await strapi.plugin("firebase-authentication").service("settingsService").restart();
|
|
25243
25243
|
return ctx.send({ status: 200 });
|
|
25244
25244
|
} catch (e) {
|
|
25245
25245
|
throw new errors.ApplicationError("some thing went wrong with restarting the server", {
|
|
@@ -25383,12 +25383,14 @@ const checkValidJson = (jsonString) => {
|
|
|
25383
25383
|
};
|
|
25384
25384
|
const { ValidationError: ValidationError3, ApplicationError: ApplicationError2 } = errors;
|
|
25385
25385
|
const settingsService = ({ strapi: strapi2 }) => {
|
|
25386
|
-
const encryptionKey = strapi2.plugin("firebase-
|
|
25386
|
+
const encryptionKey = strapi2.plugin("firebase-authentication").config("FIREBASE_JSON_ENCRYPTION_KEY");
|
|
25387
25387
|
return {
|
|
25388
25388
|
async init() {
|
|
25389
25389
|
try {
|
|
25390
25390
|
console.log("Starting Firebase initialization...");
|
|
25391
|
-
const res = await strapi2.entityService.findMany(
|
|
25391
|
+
const res = await strapi2.entityService.findMany(
|
|
25392
|
+
"plugin::firebase-authentication.firebase-authentication-configuration"
|
|
25393
|
+
);
|
|
25392
25394
|
console.log("Found config:", !!res);
|
|
25393
25395
|
if (!res) {
|
|
25394
25396
|
console.log("No config found, checking for existing Firebase app...");
|
|
@@ -25430,7 +25432,7 @@ const settingsService = ({ strapi: strapi2 }) => {
|
|
|
25430
25432
|
const key = encryptionKey;
|
|
25431
25433
|
try {
|
|
25432
25434
|
const configObject = await strapi2.entityService.findMany(
|
|
25433
|
-
"plugin::firebase-
|
|
25435
|
+
"plugin::firebase-authentication.firebase-authentication-configuration"
|
|
25434
25436
|
);
|
|
25435
25437
|
if (!configObject || !configObject["firebase_config_json"]) {
|
|
25436
25438
|
return null;
|
|
@@ -25457,16 +25459,19 @@ const settingsService = ({ strapi: strapi2 }) => {
|
|
|
25457
25459
|
const hash = await this.encryptJson(encryptionKey, firebaseConfigJsonString);
|
|
25458
25460
|
if (!firebaseConfigJson) throw new ValidationError3("data is missing");
|
|
25459
25461
|
const isExist = await strapi2.entityService.findMany(
|
|
25460
|
-
"plugin::firebase-
|
|
25462
|
+
"plugin::firebase-authentication.firebase-authentication-configuration"
|
|
25461
25463
|
);
|
|
25462
25464
|
let res;
|
|
25463
25465
|
if (!isExist) {
|
|
25464
|
-
res = await strapi2.entityService.create(
|
|
25465
|
-
|
|
25466
|
-
|
|
25466
|
+
res = await strapi2.entityService.create(
|
|
25467
|
+
"plugin::firebase-authentication.firebase-authentication-configuration",
|
|
25468
|
+
{
|
|
25469
|
+
data: { firebase_config_json: { firebaseConfigJson: hash } }
|
|
25470
|
+
}
|
|
25471
|
+
);
|
|
25467
25472
|
} else {
|
|
25468
25473
|
res = await strapi2.entityService.update(
|
|
25469
|
-
"plugin::firebase-
|
|
25474
|
+
"plugin::firebase-authentication.firebase-authentication-configuration",
|
|
25470
25475
|
isExist.id,
|
|
25471
25476
|
{
|
|
25472
25477
|
data: {
|
|
@@ -25475,7 +25480,7 @@ const settingsService = ({ strapi: strapi2 }) => {
|
|
|
25475
25480
|
}
|
|
25476
25481
|
);
|
|
25477
25482
|
}
|
|
25478
|
-
await strapi2.plugin("firebase-
|
|
25483
|
+
await strapi2.plugin("firebase-authentication").service("settingsService").init();
|
|
25479
25484
|
const firebaseConfigHash = res["firebase_config_json"].firebaseConfigJson;
|
|
25480
25485
|
const firebaseConfigJsonValue = await this.decryptJson(encryptionKey, firebaseConfigHash);
|
|
25481
25486
|
res["firebase_config_json"].firebaseConfigJson = firebaseConfigJsonValue;
|
|
@@ -25490,15 +25495,15 @@ const settingsService = ({ strapi: strapi2 }) => {
|
|
|
25490
25495
|
try {
|
|
25491
25496
|
console.log("delFirebaseConfigJson 🤣");
|
|
25492
25497
|
const isExist = await strapi2.entityService.findMany(
|
|
25493
|
-
"plugin::firebase-
|
|
25498
|
+
"plugin::firebase-authentication.firebase-authentication-configuration"
|
|
25494
25499
|
);
|
|
25495
25500
|
console.log("isExist 🤣", isExist);
|
|
25496
25501
|
const res = await strapi2.entityService.delete(
|
|
25497
|
-
"plugin::firebase-
|
|
25502
|
+
"plugin::firebase-authentication.firebase-authentication-configuration",
|
|
25498
25503
|
isExist.id
|
|
25499
25504
|
);
|
|
25500
25505
|
console.log("res 🤣", res);
|
|
25501
|
-
await strapi2.plugin("firebase-
|
|
25506
|
+
await strapi2.plugin("firebase-authentication").service("settingsService").init();
|
|
25502
25507
|
console.log("res 🤣", res);
|
|
25503
25508
|
return res;
|
|
25504
25509
|
} catch (error2) {
|
|
@@ -25614,7 +25619,7 @@ const userService = ({ strapi: strapi2 }) => ({
|
|
|
25614
25619
|
},
|
|
25615
25620
|
register: async (userID, payload) => {
|
|
25616
25621
|
try {
|
|
25617
|
-
const res = await strapi2.plugin("firebase-
|
|
25622
|
+
const res = await strapi2.plugin("firebase-authentication").service("userService").create(payload);
|
|
25618
25623
|
const actionCodeSettings = {
|
|
25619
25624
|
url: process.env.BASE_URL
|
|
25620
25625
|
};
|
|
@@ -25916,7 +25921,7 @@ const firebaseService = ({ strapi: strapi2 }) => ({
|
|
|
25916
25921
|
console.log("validateFirebaseToken 🤣");
|
|
25917
25922
|
const { profileMetaData } = ctx.request.body;
|
|
25918
25923
|
const { error: error2 } = await promiseHandler(
|
|
25919
|
-
strapi2.plugin("firebase-
|
|
25924
|
+
strapi2.plugin("firebase-authentication").service("firebaseService").validateExchangeTokenPayload(ctx.request.body)
|
|
25920
25925
|
);
|
|
25921
25926
|
if (error2) {
|
|
25922
25927
|
ctx.status = 400;
|
|
@@ -25924,15 +25929,15 @@ const firebaseService = ({ strapi: strapi2 }) => ({
|
|
|
25924
25929
|
}
|
|
25925
25930
|
const { idToken } = ctx.request.body;
|
|
25926
25931
|
const populate2 = ctx.request.query.populate || [];
|
|
25927
|
-
const decodedToken = await strapi2.plugin("firebase-
|
|
25932
|
+
const decodedToken = await strapi2.plugin("firebase-authentication").service("firebaseService").decodeIDToken(idToken);
|
|
25928
25933
|
let user;
|
|
25929
|
-
user = await strapi2.plugin("firebase-
|
|
25934
|
+
user = await strapi2.plugin("firebase-authentication").service("firebaseService").checkIfUserExists(decodedToken, profileMetaData);
|
|
25930
25935
|
let jwt;
|
|
25931
25936
|
if (!user) {
|
|
25932
|
-
user = await strapi2.plugin("firebase-
|
|
25937
|
+
user = await strapi2.plugin("firebase-authentication").service("firebaseService").createStrapiUser(decodedToken, idToken, profileMetaData);
|
|
25933
25938
|
}
|
|
25934
|
-
jwt = await strapi2.plugin("firebase-
|
|
25935
|
-
strapi2.plugin("firebase-
|
|
25939
|
+
jwt = await strapi2.plugin("firebase-authentication").service("firebaseService").generateJWTForCurrentUser(user);
|
|
25940
|
+
strapi2.plugin("firebase-authentication").service("firebaseService").updateUserIDToken(user, idToken, decodedToken);
|
|
25936
25941
|
return {
|
|
25937
25942
|
user: await processMeData(user, populate2),
|
|
25938
25943
|
jwt
|
package/dist/server/index.mjs
CHANGED
|
@@ -18,17 +18,17 @@ const bootstrap = async ({ strapi: strapi2 }) => {
|
|
|
18
18
|
section: "plugins",
|
|
19
19
|
displayName: "Allow access to the Firebase Auth interface",
|
|
20
20
|
uid: "menu-link",
|
|
21
|
-
pluginName: "firebase-
|
|
21
|
+
pluginName: "firebase-authentication"
|
|
22
22
|
}
|
|
23
23
|
];
|
|
24
|
-
await strapi2.plugin("firebase-
|
|
24
|
+
await strapi2.plugin("firebase-authentication").service("settingsService").init();
|
|
25
25
|
await strapi2.admin.services.permission.actionProvider.registerMany(actions);
|
|
26
26
|
};
|
|
27
27
|
const destroy = ({ strapi: strapi2 }) => {
|
|
28
28
|
};
|
|
29
29
|
const register = ({ strapi: strapi2 }) => {
|
|
30
30
|
strapi2.log.info("Firebase Auth Plugin registered");
|
|
31
|
-
strapi2.config.get("plugin::firebase-
|
|
31
|
+
strapi2.config.get("plugin::firebase-authentication");
|
|
32
32
|
};
|
|
33
33
|
const config = {
|
|
34
34
|
default: ({ env: env2 }) => ({
|
|
@@ -41,11 +41,11 @@ const config = {
|
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
43
|
const kind = "singleType";
|
|
44
|
-
const collectionName = "
|
|
44
|
+
const collectionName = "firebase_authentication_configurations";
|
|
45
45
|
const info = {
|
|
46
|
-
singularName: "firebase-
|
|
47
|
-
pluralName: "firebase-
|
|
48
|
-
displayName: "Firebase-
|
|
46
|
+
singularName: "firebase-authentication-configuration",
|
|
47
|
+
pluralName: "firebase-authentication-configurations",
|
|
48
|
+
displayName: "Firebase-authentication configuration"
|
|
49
49
|
};
|
|
50
50
|
const options = {
|
|
51
51
|
draftAndPublish: false
|
|
@@ -71,8 +71,8 @@ const schema$1 = {
|
|
|
71
71
|
pluginOptions,
|
|
72
72
|
attributes
|
|
73
73
|
};
|
|
74
|
-
const contentTypes = { "firebase-
|
|
75
|
-
const pluginName = "firebase-
|
|
74
|
+
const contentTypes = { "firebase-authentication-configuration": { schema: schema$1 } };
|
|
75
|
+
const pluginName = "firebase-authentication";
|
|
76
76
|
const firebaseController = {
|
|
77
77
|
async validateToken(ctx) {
|
|
78
78
|
console.log("validateToken 🤣");
|
|
@@ -25136,33 +25136,33 @@ const userController = {
|
|
|
25136
25136
|
pagination.page = 1;
|
|
25137
25137
|
pagination.pageSize = 10;
|
|
25138
25138
|
}
|
|
25139
|
-
ctx.body = await strapi.plugin("firebase-
|
|
25139
|
+
ctx.body = await strapi.plugin("firebase-authentication").service("userService").list(pagination, nextPageToken);
|
|
25140
25140
|
},
|
|
25141
25141
|
create: async (ctx) => {
|
|
25142
|
-
ctx.body = await strapi.plugin("firebase-
|
|
25142
|
+
ctx.body = await strapi.plugin("firebase-authentication").service("userService").create(ctx.request.body);
|
|
25143
25143
|
},
|
|
25144
25144
|
get: async (ctx) => {
|
|
25145
|
-
ctx.body = await strapi.plugin("firebase-
|
|
25145
|
+
ctx.body = await strapi.plugin("firebase-authentication").service("userService").get(ctx.params.id);
|
|
25146
25146
|
},
|
|
25147
25147
|
update: async (ctx) => {
|
|
25148
|
-
ctx.body = await strapi.plugin("firebase-
|
|
25148
|
+
ctx.body = await strapi.plugin("firebase-authentication").service("userService").update(ctx.params.id, ctx.request.body);
|
|
25149
25149
|
},
|
|
25150
25150
|
delete: async (ctx) => {
|
|
25151
25151
|
const { destination } = ctx.request.query;
|
|
25152
25152
|
switch (destination) {
|
|
25153
25153
|
case STRAPI_DESTINATION:
|
|
25154
|
-
ctx.body = await strapi.plugin("firebase-
|
|
25154
|
+
ctx.body = await strapi.plugin("firebase-authentication").service("userService").deleteStrapiUser(ctx.params.id);
|
|
25155
25155
|
break;
|
|
25156
25156
|
case FIREBASE_DESTINATION:
|
|
25157
|
-
ctx.body = await strapi.plugin("firebase-
|
|
25157
|
+
ctx.body = await strapi.plugin("firebase-authentication").service("userService").deleteFirebaseUser(ctx.params.id);
|
|
25158
25158
|
break;
|
|
25159
25159
|
default:
|
|
25160
|
-
ctx.body = await strapi.plugin("firebase-
|
|
25160
|
+
ctx.body = await strapi.plugin("firebase-authentication").service("userService").delete(ctx.params.id);
|
|
25161
25161
|
break;
|
|
25162
25162
|
}
|
|
25163
25163
|
},
|
|
25164
25164
|
deleteMany: async (ctx) => {
|
|
25165
|
-
ctx.body = await strapi.plugin("firebase-
|
|
25165
|
+
ctx.body = await strapi.plugin("firebase-authentication").service("userService").deleteMany(ctx.query.ids);
|
|
25166
25166
|
},
|
|
25167
25167
|
resetPassword: async (ctx) => {
|
|
25168
25168
|
const { destination } = ctx.request.query;
|
|
@@ -25171,17 +25171,17 @@ const userController = {
|
|
|
25171
25171
|
}
|
|
25172
25172
|
switch (destination) {
|
|
25173
25173
|
case STRAPI_DESTINATION:
|
|
25174
|
-
ctx.body = await strapi.plugin("firebase-
|
|
25174
|
+
ctx.body = await strapi.plugin("firebase-authentication").service("userService").resetPasswordStrapiUser(ctx.params.id, {
|
|
25175
25175
|
password: ctx.request.body.password
|
|
25176
25176
|
});
|
|
25177
25177
|
break;
|
|
25178
25178
|
case FIREBASE_DESTINATION:
|
|
25179
|
-
ctx.body = await strapi.plugin("firebase-
|
|
25179
|
+
ctx.body = await strapi.plugin("firebase-authentication").service("userService").resetPasswordFirebaseUser(ctx.params.id, {
|
|
25180
25180
|
password: ctx.request.body.password
|
|
25181
25181
|
});
|
|
25182
25182
|
break;
|
|
25183
25183
|
default:
|
|
25184
|
-
ctx.body = await strapi.plugin("firebase-
|
|
25184
|
+
ctx.body = await strapi.plugin("firebase-authentication").service("userService").resetPassword(ctx.params.id, {
|
|
25185
25185
|
password: ctx.request.body.password
|
|
25186
25186
|
});
|
|
25187
25187
|
break;
|
|
@@ -25190,14 +25190,14 @@ const userController = {
|
|
|
25190
25190
|
};
|
|
25191
25191
|
const settingsController = {
|
|
25192
25192
|
setToken: async (ctx) => {
|
|
25193
|
-
ctx.body = await strapi.plugin("firebase-
|
|
25193
|
+
ctx.body = await strapi.plugin("firebase-authentication").service("settingsService").setToken(ctx);
|
|
25194
25194
|
},
|
|
25195
25195
|
setFirebaseConfigJson: async (ctx) => {
|
|
25196
|
-
ctx.body = await strapi.plugin("firebase-
|
|
25196
|
+
ctx.body = await strapi.plugin("firebase-authentication").service("settingsService").setFirebaseConfigJson(ctx);
|
|
25197
25197
|
},
|
|
25198
25198
|
getFirebaseConfigJson: async (ctx) => {
|
|
25199
25199
|
try {
|
|
25200
|
-
const config2 = await strapi.plugin("firebase-
|
|
25200
|
+
const config2 = await strapi.plugin("firebase-authentication").service("settingsService").getFirebaseConfigJson(ctx);
|
|
25201
25201
|
if (!config2) {
|
|
25202
25202
|
return ctx.send(null);
|
|
25203
25203
|
}
|
|
@@ -25210,7 +25210,7 @@ const settingsController = {
|
|
|
25210
25210
|
},
|
|
25211
25211
|
async delFirebaseConfigJson(ctx) {
|
|
25212
25212
|
try {
|
|
25213
|
-
const isExist = await strapi.plugin("firebase-
|
|
25213
|
+
const isExist = await strapi.plugin("firebase-authentication").service("settingsService").delFirebaseConfigJson(ctx);
|
|
25214
25214
|
if (!isExist) {
|
|
25215
25215
|
throw new errors.NotFoundError("No Firebase configs exists for deletion");
|
|
25216
25216
|
}
|
|
@@ -25224,7 +25224,7 @@ const settingsController = {
|
|
|
25224
25224
|
},
|
|
25225
25225
|
async restart(ctx) {
|
|
25226
25226
|
try {
|
|
25227
|
-
await strapi.plugin("firebase-
|
|
25227
|
+
await strapi.plugin("firebase-authentication").service("settingsService").restart();
|
|
25228
25228
|
return ctx.send({ status: 200 });
|
|
25229
25229
|
} catch (e) {
|
|
25230
25230
|
throw new errors.ApplicationError("some thing went wrong with restarting the server", {
|
|
@@ -25368,12 +25368,14 @@ const checkValidJson = (jsonString) => {
|
|
|
25368
25368
|
};
|
|
25369
25369
|
const { ValidationError: ValidationError3, ApplicationError: ApplicationError2 } = errors;
|
|
25370
25370
|
const settingsService = ({ strapi: strapi2 }) => {
|
|
25371
|
-
const encryptionKey = strapi2.plugin("firebase-
|
|
25371
|
+
const encryptionKey = strapi2.plugin("firebase-authentication").config("FIREBASE_JSON_ENCRYPTION_KEY");
|
|
25372
25372
|
return {
|
|
25373
25373
|
async init() {
|
|
25374
25374
|
try {
|
|
25375
25375
|
console.log("Starting Firebase initialization...");
|
|
25376
|
-
const res = await strapi2.entityService.findMany(
|
|
25376
|
+
const res = await strapi2.entityService.findMany(
|
|
25377
|
+
"plugin::firebase-authentication.firebase-authentication-configuration"
|
|
25378
|
+
);
|
|
25377
25379
|
console.log("Found config:", !!res);
|
|
25378
25380
|
if (!res) {
|
|
25379
25381
|
console.log("No config found, checking for existing Firebase app...");
|
|
@@ -25415,7 +25417,7 @@ const settingsService = ({ strapi: strapi2 }) => {
|
|
|
25415
25417
|
const key = encryptionKey;
|
|
25416
25418
|
try {
|
|
25417
25419
|
const configObject = await strapi2.entityService.findMany(
|
|
25418
|
-
"plugin::firebase-
|
|
25420
|
+
"plugin::firebase-authentication.firebase-authentication-configuration"
|
|
25419
25421
|
);
|
|
25420
25422
|
if (!configObject || !configObject["firebase_config_json"]) {
|
|
25421
25423
|
return null;
|
|
@@ -25442,16 +25444,19 @@ const settingsService = ({ strapi: strapi2 }) => {
|
|
|
25442
25444
|
const hash = await this.encryptJson(encryptionKey, firebaseConfigJsonString);
|
|
25443
25445
|
if (!firebaseConfigJson) throw new ValidationError3("data is missing");
|
|
25444
25446
|
const isExist = await strapi2.entityService.findMany(
|
|
25445
|
-
"plugin::firebase-
|
|
25447
|
+
"plugin::firebase-authentication.firebase-authentication-configuration"
|
|
25446
25448
|
);
|
|
25447
25449
|
let res;
|
|
25448
25450
|
if (!isExist) {
|
|
25449
|
-
res = await strapi2.entityService.create(
|
|
25450
|
-
|
|
25451
|
-
|
|
25451
|
+
res = await strapi2.entityService.create(
|
|
25452
|
+
"plugin::firebase-authentication.firebase-authentication-configuration",
|
|
25453
|
+
{
|
|
25454
|
+
data: { firebase_config_json: { firebaseConfigJson: hash } }
|
|
25455
|
+
}
|
|
25456
|
+
);
|
|
25452
25457
|
} else {
|
|
25453
25458
|
res = await strapi2.entityService.update(
|
|
25454
|
-
"plugin::firebase-
|
|
25459
|
+
"plugin::firebase-authentication.firebase-authentication-configuration",
|
|
25455
25460
|
isExist.id,
|
|
25456
25461
|
{
|
|
25457
25462
|
data: {
|
|
@@ -25460,7 +25465,7 @@ const settingsService = ({ strapi: strapi2 }) => {
|
|
|
25460
25465
|
}
|
|
25461
25466
|
);
|
|
25462
25467
|
}
|
|
25463
|
-
await strapi2.plugin("firebase-
|
|
25468
|
+
await strapi2.plugin("firebase-authentication").service("settingsService").init();
|
|
25464
25469
|
const firebaseConfigHash = res["firebase_config_json"].firebaseConfigJson;
|
|
25465
25470
|
const firebaseConfigJsonValue = await this.decryptJson(encryptionKey, firebaseConfigHash);
|
|
25466
25471
|
res["firebase_config_json"].firebaseConfigJson = firebaseConfigJsonValue;
|
|
@@ -25475,15 +25480,15 @@ const settingsService = ({ strapi: strapi2 }) => {
|
|
|
25475
25480
|
try {
|
|
25476
25481
|
console.log("delFirebaseConfigJson 🤣");
|
|
25477
25482
|
const isExist = await strapi2.entityService.findMany(
|
|
25478
|
-
"plugin::firebase-
|
|
25483
|
+
"plugin::firebase-authentication.firebase-authentication-configuration"
|
|
25479
25484
|
);
|
|
25480
25485
|
console.log("isExist 🤣", isExist);
|
|
25481
25486
|
const res = await strapi2.entityService.delete(
|
|
25482
|
-
"plugin::firebase-
|
|
25487
|
+
"plugin::firebase-authentication.firebase-authentication-configuration",
|
|
25483
25488
|
isExist.id
|
|
25484
25489
|
);
|
|
25485
25490
|
console.log("res 🤣", res);
|
|
25486
|
-
await strapi2.plugin("firebase-
|
|
25491
|
+
await strapi2.plugin("firebase-authentication").service("settingsService").init();
|
|
25487
25492
|
console.log("res 🤣", res);
|
|
25488
25493
|
return res;
|
|
25489
25494
|
} catch (error2) {
|
|
@@ -25599,7 +25604,7 @@ const userService = ({ strapi: strapi2 }) => ({
|
|
|
25599
25604
|
},
|
|
25600
25605
|
register: async (userID, payload) => {
|
|
25601
25606
|
try {
|
|
25602
|
-
const res = await strapi2.plugin("firebase-
|
|
25607
|
+
const res = await strapi2.plugin("firebase-authentication").service("userService").create(payload);
|
|
25603
25608
|
const actionCodeSettings = {
|
|
25604
25609
|
url: process.env.BASE_URL
|
|
25605
25610
|
};
|
|
@@ -25901,7 +25906,7 @@ const firebaseService = ({ strapi: strapi2 }) => ({
|
|
|
25901
25906
|
console.log("validateFirebaseToken 🤣");
|
|
25902
25907
|
const { profileMetaData } = ctx.request.body;
|
|
25903
25908
|
const { error: error2 } = await promiseHandler(
|
|
25904
|
-
strapi2.plugin("firebase-
|
|
25909
|
+
strapi2.plugin("firebase-authentication").service("firebaseService").validateExchangeTokenPayload(ctx.request.body)
|
|
25905
25910
|
);
|
|
25906
25911
|
if (error2) {
|
|
25907
25912
|
ctx.status = 400;
|
|
@@ -25909,15 +25914,15 @@ const firebaseService = ({ strapi: strapi2 }) => ({
|
|
|
25909
25914
|
}
|
|
25910
25915
|
const { idToken } = ctx.request.body;
|
|
25911
25916
|
const populate2 = ctx.request.query.populate || [];
|
|
25912
|
-
const decodedToken = await strapi2.plugin("firebase-
|
|
25917
|
+
const decodedToken = await strapi2.plugin("firebase-authentication").service("firebaseService").decodeIDToken(idToken);
|
|
25913
25918
|
let user;
|
|
25914
|
-
user = await strapi2.plugin("firebase-
|
|
25919
|
+
user = await strapi2.plugin("firebase-authentication").service("firebaseService").checkIfUserExists(decodedToken, profileMetaData);
|
|
25915
25920
|
let jwt;
|
|
25916
25921
|
if (!user) {
|
|
25917
|
-
user = await strapi2.plugin("firebase-
|
|
25922
|
+
user = await strapi2.plugin("firebase-authentication").service("firebaseService").createStrapiUser(decodedToken, idToken, profileMetaData);
|
|
25918
25923
|
}
|
|
25919
|
-
jwt = await strapi2.plugin("firebase-
|
|
25920
|
-
strapi2.plugin("firebase-
|
|
25924
|
+
jwt = await strapi2.plugin("firebase-authentication").service("firebaseService").generateJWTForCurrentUser(user);
|
|
25925
|
+
strapi2.plugin("firebase-authentication").service("firebaseService").updateUserIDToken(user, idToken, decodedToken);
|
|
25921
25926
|
return {
|
|
25922
25927
|
user: await processMeData(user, populate2),
|
|
25923
25928
|
jwt
|
|
@@ -113,7 +113,9 @@ declare const _default: {
|
|
|
113
113
|
deleteMany: (entityIDs: any) => Promise<any>;
|
|
114
114
|
setSocialMetaData(): Promise<void>;
|
|
115
115
|
};
|
|
116
|
-
firebaseService: ({ strapi }:
|
|
116
|
+
firebaseService: ({ strapi }: {
|
|
117
|
+
strapi: any;
|
|
118
|
+
}) => {
|
|
117
119
|
getUserAttributes(): Promise<any>;
|
|
118
120
|
delete: (entityId: any) => Promise<{
|
|
119
121
|
success: boolean;
|
|
@@ -142,7 +144,7 @@ declare const _default: {
|
|
|
142
144
|
};
|
|
143
145
|
};
|
|
144
146
|
contentTypes: {
|
|
145
|
-
"firebase-
|
|
147
|
+
"firebase-authentication-configuration": {
|
|
146
148
|
schema: {
|
|
147
149
|
kind: string;
|
|
148
150
|
collectionName: string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
declare const _default: ({ strapi }: {
|
|
2
|
+
strapi: any;
|
|
3
|
+
}) => {
|
|
3
4
|
getUserAttributes(): Promise<any>;
|
|
4
5
|
delete: (entityId: any) => Promise<{
|
|
5
6
|
success: boolean;
|
|
@@ -37,7 +37,9 @@ declare const _default: {
|
|
|
37
37
|
deleteMany: (entityIDs: any) => Promise<any>;
|
|
38
38
|
setSocialMetaData(): Promise<void>;
|
|
39
39
|
};
|
|
40
|
-
firebaseService: ({ strapi }:
|
|
40
|
+
firebaseService: ({ strapi }: {
|
|
41
|
+
strapi: any;
|
|
42
|
+
}) => {
|
|
41
43
|
getUserAttributes(): Promise<any>;
|
|
42
44
|
delete: (entityId: any) => Promise<{
|
|
43
45
|
success: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "strapi-plugin-firebase-authentication",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Allows easy integration between clients utilizing Firebase for authentication and Strapi",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"access": "public",
|
|
87
87
|
"strapi": {
|
|
88
88
|
"kind": "plugin",
|
|
89
|
-
"name": "firebase-
|
|
89
|
+
"name": "firebase-authentication",
|
|
90
90
|
"displayName": "Strapi <-> Firebase Auth Plugin",
|
|
91
91
|
"description": "Allows easy integration between clients utilizing Firebase for authentication and Strapi"
|
|
92
92
|
}
|
|
File without changes
|
|
File without changes
|