@dereekb/firebase-server 12.1.3 → 12.1.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/CHANGELOG.md +4 -0
- package/mailgun/package.json +1 -1
- package/model/package.json +1 -1
- package/package.json +10 -4
- package/test/package.json +1 -1
- package/zoho/LICENSE +21 -0
- package/zoho/index.cjs.d.ts +1 -0
- package/zoho/index.cjs.js +108 -0
- package/zoho/index.esm.d.ts +1 -0
- package/zoho/index.esm.js +102 -0
- package/zoho/package.json +22 -4
- package/zoho/src/index.js +0 -5
- package/zoho/src/index.js.map +0 -1
- package/zoho/src/lib/index.js +0 -6
- package/zoho/src/lib/index.js.map +0 -1
- package/zoho/src/lib/zoho.accounts.firebase.js +0 -61
- package/zoho/src/lib/zoho.accounts.firebase.js.map +0 -1
- package/zoho/src/lib/zoho.accounts.firebase.system.js +0 -44
- package/zoho/src/lib/zoho.accounts.firebase.system.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [12.1.4](https://github.com/dereekb/dbx-components/compare/v12.1.3-dev...v12.1.4) (2025-05-22)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
5
9
|
## [12.1.3](https://github.com/dereekb/dbx-components/compare/v12.1.2-dev...v12.1.3) (2025-05-20)
|
|
6
10
|
|
|
7
11
|
|
package/mailgun/package.json
CHANGED
package/model/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/firebase-server",
|
|
3
|
-
"version": "12.1.
|
|
3
|
+
"version": "12.1.4",
|
|
4
4
|
"exports": {
|
|
5
5
|
".": {
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
@@ -22,9 +22,15 @@
|
|
|
22
22
|
},
|
|
23
23
|
"./zoho": {
|
|
24
24
|
"types": "./zoho/src/index.d.ts",
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
25
|
+
"module": "./zoho/index.esm.js",
|
|
26
|
+
"main": "./zoho/index.cjs.js",
|
|
27
|
+
"node": {
|
|
28
|
+
"require": "./zoho/index.cjs.js"
|
|
29
|
+
},
|
|
30
|
+
"browser": {
|
|
31
|
+
"require": "./zoho/index.cjs.js",
|
|
32
|
+
"import": "./zoho/index.esm.js"
|
|
33
|
+
}
|
|
28
34
|
},
|
|
29
35
|
"./model": {
|
|
30
36
|
"types": "./model/src/index.d.ts",
|
package/test/package.json
CHANGED
package/zoho/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Hapier Creative LLC.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/index";
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var firebase = require('@dereekb/firebase');
|
|
4
|
+
var util = require('@dereekb/util');
|
|
5
|
+
|
|
6
|
+
const ZOHO_ACCESS_TOKEN_SYSTEM_STATE_TYPE = 'zoho_access_token';
|
|
7
|
+
const zohoAccessTokenSystemStateEmbeddedTokenConverter = firebase.firestoreSubObject({
|
|
8
|
+
objectField: {
|
|
9
|
+
fields: {
|
|
10
|
+
key: firebase.firestoreString(),
|
|
11
|
+
accessToken: firebase.firestoreString(),
|
|
12
|
+
scope: firebase.firestoreString(),
|
|
13
|
+
apiDomain: firebase.firestoreString(),
|
|
14
|
+
expiresIn: firebase.firestoreNumber({
|
|
15
|
+
default: 3600
|
|
16
|
+
}),
|
|
17
|
+
expiresAt: firebase.firestoreDate()
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
/**
|
|
22
|
+
* NOTE: Be sure to register this data converter with the SystemStateStoredDataConverterMap for your app.
|
|
23
|
+
*/
|
|
24
|
+
const zohoAccessTokenSystemStateDataConverter = firebase.firestoreSubObject({
|
|
25
|
+
objectField: {
|
|
26
|
+
fields: {
|
|
27
|
+
tokens: firebase.firestoreObjectArray({
|
|
28
|
+
firestoreField: zohoAccessTokenSystemStateEmbeddedTokenConverter,
|
|
29
|
+
filterUnique: util.filterUniqueFunction(x => x.key),
|
|
30
|
+
// only one token per key is allowed
|
|
31
|
+
filter: x => x?.expiresAt ? !util.isPast(x.expiresAt) : true // filter out expired values or values that have no expiration
|
|
32
|
+
}),
|
|
33
|
+
lat: firebase.firestoreDate({
|
|
34
|
+
saveDefaultAsNow: true
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
/**
|
|
40
|
+
* Convenience function for loading the document for ZohoAccessTokenSystemStateData.
|
|
41
|
+
*
|
|
42
|
+
* @param accessor
|
|
43
|
+
* @returns
|
|
44
|
+
*/
|
|
45
|
+
function loadZohoAccessTokenSystemState(accessor) {
|
|
46
|
+
return accessor.loadDocumentForId(ZOHO_ACCESS_TOKEN_SYSTEM_STATE_TYPE);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Creates a ZohoAccountsAccessTokenCacheService from the input SystemStateFirestoreCollection.
|
|
51
|
+
*
|
|
52
|
+
* @param collection
|
|
53
|
+
*/
|
|
54
|
+
function firebaseZohoAccountsAccessTokenCacheService(systemStateCollection) {
|
|
55
|
+
const systemStateDocumentAccessor = systemStateCollection.documentAccessor();
|
|
56
|
+
const service = {
|
|
57
|
+
loadZohoAccessTokenCache: function (serviceKey) {
|
|
58
|
+
const cache = {
|
|
59
|
+
loadCachedToken: async function () {
|
|
60
|
+
const document = loadZohoAccessTokenSystemState(systemStateDocumentAccessor);
|
|
61
|
+
const existingData = await document.snapshotData();
|
|
62
|
+
let result = null;
|
|
63
|
+
if (existingData != null) {
|
|
64
|
+
const tokensArray = existingData?.data?.tokens ?? [];
|
|
65
|
+
result = tokensArray.find(x => x.key === serviceKey);
|
|
66
|
+
}
|
|
67
|
+
return result;
|
|
68
|
+
},
|
|
69
|
+
updateCachedToken: async function (accessToken) {
|
|
70
|
+
// run in a transaction
|
|
71
|
+
await systemStateCollection.firestoreContext.runTransaction(async transaction => {
|
|
72
|
+
const documentInTransaction = loadZohoAccessTokenSystemState(systemStateCollection.documentAccessorForTransaction(transaction));
|
|
73
|
+
const existingData = await documentInTransaction.snapshotData();
|
|
74
|
+
const existingTokens = existingData?.data?.tokens ?? [];
|
|
75
|
+
const tokens = [
|
|
76
|
+
// filter any potential old token for this service key
|
|
77
|
+
...existingTokens.filter(x => x.key !== serviceKey),
|
|
78
|
+
// add the new token
|
|
79
|
+
{
|
|
80
|
+
...accessToken,
|
|
81
|
+
key: serviceKey
|
|
82
|
+
}];
|
|
83
|
+
const templateOrUpdate = {
|
|
84
|
+
data: {
|
|
85
|
+
tokens,
|
|
86
|
+
lat: new Date()
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
// create/update depending on the current document's existence
|
|
90
|
+
if (!existingData) {
|
|
91
|
+
await documentInTransaction.create(templateOrUpdate);
|
|
92
|
+
} else {
|
|
93
|
+
await documentInTransaction.update(templateOrUpdate);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
return cache;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
return service;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
exports.ZOHO_ACCESS_TOKEN_SYSTEM_STATE_TYPE = ZOHO_ACCESS_TOKEN_SYSTEM_STATE_TYPE;
|
|
105
|
+
exports.firebaseZohoAccountsAccessTokenCacheService = firebaseZohoAccountsAccessTokenCacheService;
|
|
106
|
+
exports.loadZohoAccessTokenSystemState = loadZohoAccessTokenSystemState;
|
|
107
|
+
exports.zohoAccessTokenSystemStateDataConverter = zohoAccessTokenSystemStateDataConverter;
|
|
108
|
+
exports.zohoAccessTokenSystemStateEmbeddedTokenConverter = zohoAccessTokenSystemStateEmbeddedTokenConverter;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/index";
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { firestoreSubObject, firestoreString, firestoreNumber, firestoreDate, firestoreObjectArray } from '@dereekb/firebase';
|
|
2
|
+
import { filterUniqueFunction, isPast } from '@dereekb/util';
|
|
3
|
+
|
|
4
|
+
const ZOHO_ACCESS_TOKEN_SYSTEM_STATE_TYPE = 'zoho_access_token';
|
|
5
|
+
const zohoAccessTokenSystemStateEmbeddedTokenConverter = firestoreSubObject({
|
|
6
|
+
objectField: {
|
|
7
|
+
fields: {
|
|
8
|
+
key: firestoreString(),
|
|
9
|
+
accessToken: firestoreString(),
|
|
10
|
+
scope: firestoreString(),
|
|
11
|
+
apiDomain: firestoreString(),
|
|
12
|
+
expiresIn: firestoreNumber({
|
|
13
|
+
default: 3600
|
|
14
|
+
}),
|
|
15
|
+
expiresAt: firestoreDate()
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* NOTE: Be sure to register this data converter with the SystemStateStoredDataConverterMap for your app.
|
|
21
|
+
*/
|
|
22
|
+
const zohoAccessTokenSystemStateDataConverter = firestoreSubObject({
|
|
23
|
+
objectField: {
|
|
24
|
+
fields: {
|
|
25
|
+
tokens: firestoreObjectArray({
|
|
26
|
+
firestoreField: zohoAccessTokenSystemStateEmbeddedTokenConverter,
|
|
27
|
+
filterUnique: filterUniqueFunction(x => x.key),
|
|
28
|
+
// only one token per key is allowed
|
|
29
|
+
filter: x => x?.expiresAt ? !isPast(x.expiresAt) : true // filter out expired values or values that have no expiration
|
|
30
|
+
}),
|
|
31
|
+
lat: firestoreDate({
|
|
32
|
+
saveDefaultAsNow: true
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
/**
|
|
38
|
+
* Convenience function for loading the document for ZohoAccessTokenSystemStateData.
|
|
39
|
+
*
|
|
40
|
+
* @param accessor
|
|
41
|
+
* @returns
|
|
42
|
+
*/
|
|
43
|
+
function loadZohoAccessTokenSystemState(accessor) {
|
|
44
|
+
return accessor.loadDocumentForId(ZOHO_ACCESS_TOKEN_SYSTEM_STATE_TYPE);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Creates a ZohoAccountsAccessTokenCacheService from the input SystemStateFirestoreCollection.
|
|
49
|
+
*
|
|
50
|
+
* @param collection
|
|
51
|
+
*/
|
|
52
|
+
function firebaseZohoAccountsAccessTokenCacheService(systemStateCollection) {
|
|
53
|
+
const systemStateDocumentAccessor = systemStateCollection.documentAccessor();
|
|
54
|
+
const service = {
|
|
55
|
+
loadZohoAccessTokenCache: function (serviceKey) {
|
|
56
|
+
const cache = {
|
|
57
|
+
loadCachedToken: async function () {
|
|
58
|
+
const document = loadZohoAccessTokenSystemState(systemStateDocumentAccessor);
|
|
59
|
+
const existingData = await document.snapshotData();
|
|
60
|
+
let result = null;
|
|
61
|
+
if (existingData != null) {
|
|
62
|
+
const tokensArray = existingData?.data?.tokens ?? [];
|
|
63
|
+
result = tokensArray.find(x => x.key === serviceKey);
|
|
64
|
+
}
|
|
65
|
+
return result;
|
|
66
|
+
},
|
|
67
|
+
updateCachedToken: async function (accessToken) {
|
|
68
|
+
// run in a transaction
|
|
69
|
+
await systemStateCollection.firestoreContext.runTransaction(async transaction => {
|
|
70
|
+
const documentInTransaction = loadZohoAccessTokenSystemState(systemStateCollection.documentAccessorForTransaction(transaction));
|
|
71
|
+
const existingData = await documentInTransaction.snapshotData();
|
|
72
|
+
const existingTokens = existingData?.data?.tokens ?? [];
|
|
73
|
+
const tokens = [
|
|
74
|
+
// filter any potential old token for this service key
|
|
75
|
+
...existingTokens.filter(x => x.key !== serviceKey),
|
|
76
|
+
// add the new token
|
|
77
|
+
{
|
|
78
|
+
...accessToken,
|
|
79
|
+
key: serviceKey
|
|
80
|
+
}];
|
|
81
|
+
const templateOrUpdate = {
|
|
82
|
+
data: {
|
|
83
|
+
tokens,
|
|
84
|
+
lat: new Date()
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
// create/update depending on the current document's existence
|
|
88
|
+
if (!existingData) {
|
|
89
|
+
await documentInTransaction.create(templateOrUpdate);
|
|
90
|
+
} else {
|
|
91
|
+
await documentInTransaction.update(templateOrUpdate);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
return cache;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
return service;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export { ZOHO_ACCESS_TOKEN_SYSTEM_STATE_TYPE, firebaseZohoAccountsAccessTokenCacheService, loadZohoAccessTokenSystemState, zohoAccessTokenSystemStateDataConverter, zohoAccessTokenSystemStateEmbeddedTokenConverter };
|
package/zoho/package.json
CHANGED
|
@@ -1,7 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/firebase-server/zoho",
|
|
3
|
-
"version": "12.1.
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
"version": "12.1.4",
|
|
4
|
+
"exports": {
|
|
5
|
+
".": {
|
|
6
|
+
"types": "./src/index.d.ts",
|
|
7
|
+
"node": {
|
|
8
|
+
"require": "./index.cjs.js"
|
|
9
|
+
},
|
|
10
|
+
"browser": {
|
|
11
|
+
"require": "./index.cjs.js",
|
|
12
|
+
"import": "./index.esm.js"
|
|
13
|
+
},
|
|
14
|
+
"default": "./index.cjs.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"peerDependencies": {
|
|
18
|
+
"@dereekb/firebase": "*",
|
|
19
|
+
"@dereekb/util": "*",
|
|
20
|
+
"@dereekb/zoho": "*"
|
|
21
|
+
},
|
|
22
|
+
"module": "./index.esm.js",
|
|
23
|
+
"main": "./index.cjs.js",
|
|
24
|
+
"types": "./index.esm.d.ts"
|
|
7
25
|
}
|
package/zoho/src/index.js
DELETED
package/zoho/src/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/firebase-server/zoho/src/index.ts"],"names":[],"mappings":";;;AAAA,gDAAsB"}
|
package/zoho/src/lib/index.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./zoho.accounts.firebase"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./zoho.accounts.firebase.system"), exports);
|
|
6
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/firebase-server/zoho/src/lib/index.ts"],"names":[],"mappings":";;;AAAA,mEAAyC;AACzC,0EAAgD"}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.firebaseZohoAccountsAccessTokenCacheService = firebaseZohoAccountsAccessTokenCacheService;
|
|
4
|
-
const zoho_accounts_firebase_system_1 = require("./zoho.accounts.firebase.system");
|
|
5
|
-
/**
|
|
6
|
-
* Creates a ZohoAccountsAccessTokenCacheService from the input SystemStateFirestoreCollection.
|
|
7
|
-
*
|
|
8
|
-
* @param collection
|
|
9
|
-
*/
|
|
10
|
-
function firebaseZohoAccountsAccessTokenCacheService(systemStateCollection) {
|
|
11
|
-
const systemStateDocumentAccessor = systemStateCollection.documentAccessor();
|
|
12
|
-
const service = {
|
|
13
|
-
loadZohoAccessTokenCache: function (serviceKey) {
|
|
14
|
-
const cache = {
|
|
15
|
-
loadCachedToken: async function () {
|
|
16
|
-
const document = (0, zoho_accounts_firebase_system_1.loadZohoAccessTokenSystemState)(systemStateDocumentAccessor);
|
|
17
|
-
const existingData = await document.snapshotData();
|
|
18
|
-
let result = null;
|
|
19
|
-
if (existingData != null) {
|
|
20
|
-
const tokensArray = existingData?.data?.tokens ?? [];
|
|
21
|
-
result = tokensArray.find((x) => x.key === serviceKey);
|
|
22
|
-
}
|
|
23
|
-
return result;
|
|
24
|
-
},
|
|
25
|
-
updateCachedToken: async function (accessToken) {
|
|
26
|
-
// run in a transaction
|
|
27
|
-
await systemStateCollection.firestoreContext.runTransaction(async (transaction) => {
|
|
28
|
-
const documentInTransaction = (0, zoho_accounts_firebase_system_1.loadZohoAccessTokenSystemState)(systemStateCollection.documentAccessorForTransaction(transaction));
|
|
29
|
-
const existingData = await documentInTransaction.snapshotData();
|
|
30
|
-
const existingTokens = existingData?.data?.tokens ?? [];
|
|
31
|
-
const tokens = [
|
|
32
|
-
// filter any potential old token for this service key
|
|
33
|
-
...existingTokens.filter((x) => x.key !== serviceKey),
|
|
34
|
-
// add the new token
|
|
35
|
-
{
|
|
36
|
-
...accessToken,
|
|
37
|
-
key: serviceKey
|
|
38
|
-
}
|
|
39
|
-
];
|
|
40
|
-
const templateOrUpdate = {
|
|
41
|
-
data: {
|
|
42
|
-
tokens,
|
|
43
|
-
lat: new Date()
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
// create/update depending on the current document's existence
|
|
47
|
-
if (!existingData) {
|
|
48
|
-
await documentInTransaction.create(templateOrUpdate);
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
await documentInTransaction.update(templateOrUpdate);
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
return cache;
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
return service;
|
|
60
|
-
}
|
|
61
|
-
//# sourceMappingURL=zoho.accounts.firebase.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"zoho.accounts.firebase.js","sourceRoot":"","sources":["../../../../../../packages/firebase-server/zoho/src/lib/zoho.accounts.firebase.ts"],"names":[],"mappings":";;AAWA,kGA0DC;AAjED,mFAAsH;AAEtH;;;;GAIG;AACH,SAAgB,2CAA2C,CAAC,qBAAqD;IAC/G,MAAM,2BAA2B,GAAG,qBAAqB,CAAC,gBAAgB,EAAE,CAAC;IAE7E,MAAM,OAAO,GAAwC;QACnD,wBAAwB,EAAE,UAAU,UAAkB;YACpD,MAAM,KAAK,GAAyB;gBAClC,eAAe,EAAE,KAAK;oBACpB,MAAM,QAAQ,GAAG,IAAA,8DAA8B,EAAC,2BAA2B,CAAC,CAAC;oBAC7E,MAAM,YAAY,GAAG,MAAM,QAAQ,CAAC,YAAY,EAAE,CAAC;oBAEnD,I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AAC;wBACvD,CAAC;oBACH,CAAC,CAAC,CAAC;gBACL,CAAC;aACF,CAAC;YAEF,OAAO,KAAK,CAAC;QACf,CAAC;KACF,CAAC;IAEF,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.zohoAccessTokenSystemStateDataConverter = exports.zohoAccessTokenSystemStateEmbeddedTokenConverter = exports.ZOHO_ACCESS_TOKEN_SYSTEM_STATE_TYPE = void 0;
|
|
4
|
-
exports.loadZohoAccessTokenSystemState = loadZohoAccessTokenSystemState;
|
|
5
|
-
const firebase_1 = require("@dereekb/firebase");
|
|
6
|
-
const util_1 = require("@dereekb/util");
|
|
7
|
-
exports.ZOHO_ACCESS_TOKEN_SYSTEM_STATE_TYPE = 'zoho_access_token';
|
|
8
|
-
exports.zohoAccessTokenSystemStateEmbeddedTokenConverter = (0, firebase_1.firestoreSubObject)({
|
|
9
|
-
objectField: {
|
|
10
|
-
fields: {
|
|
11
|
-
key: (0, firebase_1.firestoreString)(),
|
|
12
|
-
accessToken: (0, firebase_1.firestoreString)(),
|
|
13
|
-
scope: (0, firebase_1.firestoreString)(),
|
|
14
|
-
apiDomain: (0, firebase_1.firestoreString)(),
|
|
15
|
-
expiresIn: (0, firebase_1.firestoreNumber)({ default: 3600 }),
|
|
16
|
-
expiresAt: (0, firebase_1.firestoreDate)()
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
/**
|
|
21
|
-
* NOTE: Be sure to register this data converter with the SystemStateStoredDataConverterMap for your app.
|
|
22
|
-
*/
|
|
23
|
-
exports.zohoAccessTokenSystemStateDataConverter = (0, firebase_1.firestoreSubObject)({
|
|
24
|
-
objectField: {
|
|
25
|
-
fields: {
|
|
26
|
-
tokens: (0, firebase_1.firestoreObjectArray)({
|
|
27
|
-
firestoreField: exports.zohoAccessTokenSystemStateEmbeddedTokenConverter,
|
|
28
|
-
filterUnique: (0, util_1.filterUniqueFunction)((x) => x.key), // only one token per key is allowed
|
|
29
|
-
filter: (x) => (x?.expiresAt ? !(0, util_1.isPast)(x.expiresAt) : true) // filter out expired values or values that have no expiration
|
|
30
|
-
}),
|
|
31
|
-
lat: (0, firebase_1.firestoreDate)({ saveDefaultAsNow: true })
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
/**
|
|
36
|
-
* Convenience function for loading the document for ZohoAccessTokenSystemStateData.
|
|
37
|
-
*
|
|
38
|
-
* @param accessor
|
|
39
|
-
* @returns
|
|
40
|
-
*/
|
|
41
|
-
function loadZohoAccessTokenSystemState(accessor) {
|
|
42
|
-
return accessor.loadDocumentForId(exports.ZOHO_ACCESS_TOKEN_SYSTEM_STATE_TYPE);
|
|
43
|
-
}
|
|
44
|
-
//# sourceMappingURL=zoho.accounts.firebase.system.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"zoho.accounts.firebase.system.js","sourceRoot":"","sources":["../../../../../../packages/firebase-server/zoho/src/lib/zoho.accounts.firebase.system.ts"],"names":[],"mappings":";;;AA2DA,wEAEC;AA5DD,gDAAsR;AACtR,wCAAgF;AAEnE,QAAA,mCAAmC,GAAG,mBAAmB,CAAC;AAS1D,QAAA,gDAAgD,GAAG,IAAA,6BAAkB,EAA0C;IAC1H,WAAW,EAAE;QACX,MAAM,EAAE;YACN,GAAG,EAAE,IAAA,0BAAe,GAAE;YACtB,WAAW,EAAE,IAAA,0BAAe,GAAE;YAC9B,KAAK,EAAE,IAAA,0BAAe,GAAE;YACxB,SAAS,EAAE,IAAA,0BAAe,GAAE;YAC5B,SAAS,EAAE,IAAA,0BAAe,EAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;YAC7C,SAAS,EAAE,IAAA,wBAAa,GAAE;SAC3B;KACF;CACF,CAAC,CAAC;AAaH;;GAEG;AACU,QAAA,uCAAuC,GAA8E,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