@dereekb/zoom 13.32.0 → 13.34.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/index.cjs.js +120 -65
- package/index.esm.js +118 -66
- package/nestjs/index.cjs.js +11 -20
- package/nestjs/index.esm.js +11 -20
- package/nestjs/package.json +5 -5
- package/nestjs/src/lib/oauth/oauth.config.d.ts +8 -3
- package/package.json +4 -4
- package/src/lib/oauth/oauth.config.d.ts +70 -9
- package/src/lib/oauth/oauth.factory.d.ts +18 -1
- package/src/lib/zoom/zoom.config.d.ts +10 -22
package/index.cjs.js
CHANGED
|
@@ -1656,14 +1656,17 @@ function _ts_generator$1(thisArg, body) {
|
|
|
1656
1656
|
});
|
|
1657
1657
|
// MARK: Make User Context
|
|
1658
1658
|
var makeUserContext = function makeUserContext(input) {
|
|
1659
|
-
var userAccessTokenFactory = oauthContext.
|
|
1659
|
+
var userAccessTokenFactory = oauthContext.makeAccessTokenFactory({
|
|
1660
1660
|
refreshToken: input.refreshToken,
|
|
1661
|
-
|
|
1661
|
+
accessTokenCache: input.accessTokenCache
|
|
1662
1662
|
});
|
|
1663
1663
|
var userAccessTokenStringFactory = zoomAccessTokenStringFactory(userAccessTokenFactory);
|
|
1664
|
-
var
|
|
1664
|
+
var userBaseFetch = fetchFactory({
|
|
1665
1665
|
zoomAccessTokenStringFactory: userAccessTokenStringFactory
|
|
1666
1666
|
});
|
|
1667
|
+
// wrapped for the same reason the server fetch is: without it a per-user call's error skips
|
|
1668
|
+
// Zoom's parsed error family and its rate-limit header handling
|
|
1669
|
+
var userFetch = handleZoomErrorFetch(userBaseFetch, logZoomServerErrorFunction);
|
|
1667
1670
|
var userFetchJson = fetch.fetchJsonFunction(userFetch, {
|
|
1668
1671
|
handleFetchJsonParseErrorFunction: fetch.returnNullHandleFetchJsonParseErrorFunction
|
|
1669
1672
|
});
|
|
@@ -1752,6 +1755,36 @@ function _ts_generator$1(thisArg, body) {
|
|
|
1752
1755
|
/**
|
|
1753
1756
|
* The Zoom OAuth API URL for the US datacenter.
|
|
1754
1757
|
*/ var ZOOM_OAUTH_API_URL = 'https://zoom.us/oauth';
|
|
1758
|
+
/**
|
|
1759
|
+
* Returns whether the credential is a {@link ZoomRefreshTokenCredential}.
|
|
1760
|
+
*
|
|
1761
|
+
* Checked before the account arm on purpose: `accountId` is also ambient on {@link ZoomOAuthConfig},
|
|
1762
|
+
* so a credential carrying both reads as a user credential that picked up an accountId — never the
|
|
1763
|
+
* reverse.
|
|
1764
|
+
*
|
|
1765
|
+
* @param credential - The credential to check.
|
|
1766
|
+
* @returns True when the credential carries a refresh token.
|
|
1767
|
+
*
|
|
1768
|
+
* @__NO_SIDE_EFFECTS__
|
|
1769
|
+
*/ function isZoomRefreshTokenCredential(credential) {
|
|
1770
|
+
return credential.refreshToken != null;
|
|
1771
|
+
}
|
|
1772
|
+
/**
|
|
1773
|
+
* The ambient credential a {@link ZoomOAuthConfig} authenticates the app's own calls with.
|
|
1774
|
+
*
|
|
1775
|
+
* Zoom's ambient credential is fully determined by the config — there is no choice to configure, so
|
|
1776
|
+
* it is derived here rather than being a settable field.
|
|
1777
|
+
*
|
|
1778
|
+
* @param config - The OAuth configuration.
|
|
1779
|
+
* @returns The account credential for that configuration.
|
|
1780
|
+
*
|
|
1781
|
+
* @__NO_SIDE_EFFECTS__
|
|
1782
|
+
*/ function zoomOAuthConfigAccountCredential(config) {
|
|
1783
|
+
return {
|
|
1784
|
+
accountId: config.accountId,
|
|
1785
|
+
accessTokenCache: config.accessTokenCache
|
|
1786
|
+
};
|
|
1787
|
+
}
|
|
1755
1788
|
|
|
1756
1789
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
1757
1790
|
try {
|
|
@@ -1881,6 +1914,25 @@ function _ts_generator(thisArg, body) {
|
|
|
1881
1914
|
};
|
|
1882
1915
|
}
|
|
1883
1916
|
}
|
|
1917
|
+
/**
|
|
1918
|
+
* Maps a {@link ZoomOAuthAccessTokenResponse} to a {@link ZoomAccessToken}.
|
|
1919
|
+
*
|
|
1920
|
+
* @param response - The token response returned by the Zoom token endpoint.
|
|
1921
|
+
* @returns The equivalent ZoomAccessToken, with `expiresAt` resolved against the current time.
|
|
1922
|
+
*
|
|
1923
|
+
* @__NO_SIDE_EFFECTS__
|
|
1924
|
+
*/ function zoomAccessTokenFromTokenResponse(response) {
|
|
1925
|
+
var createdAt = Date.now();
|
|
1926
|
+
var access_token = response.access_token, api_url = response.api_url, scope = response.scope, expires_in = response.expires_in;
|
|
1927
|
+
var accessToken = {
|
|
1928
|
+
accessToken: access_token,
|
|
1929
|
+
apiDomain: api_url,
|
|
1930
|
+
expiresIn: expires_in,
|
|
1931
|
+
expiresAt: new Date(createdAt + expires_in * util.MS_IN_SECOND),
|
|
1932
|
+
scope: scope
|
|
1933
|
+
};
|
|
1934
|
+
return accessToken;
|
|
1935
|
+
}
|
|
1884
1936
|
/**
|
|
1885
1937
|
* Creates a ZoomOAuth instance factory from the given configuration.
|
|
1886
1938
|
*
|
|
@@ -1889,7 +1941,8 @@ function _ts_generator(thisArg, body) {
|
|
|
1889
1941
|
*
|
|
1890
1942
|
* @__NO_SIDE_EFFECTS__
|
|
1891
1943
|
*/ function zoomOAuthFactory(factoryConfig) {
|
|
1892
|
-
var
|
|
1944
|
+
var _factoryConfig_fetchHandler;
|
|
1945
|
+
var fetchHandler = (_factoryConfig_fetchHandler = factoryConfig.fetchHandler) !== null && _factoryConfig_fetchHandler !== void 0 ? _factoryConfig_fetchHandler : zoomRateLimitedFetchHandler();
|
|
1893
1946
|
var logZoomServerErrorFunction = factoryConfig.logZoomServerErrorFunction, _factoryConfig_fetchFactory = factoryConfig.fetchFactory, fetchFactory = _factoryConfig_fetchFactory === void 0 ? function() {
|
|
1894
1947
|
return fetch.fetchApiFetchService.makeFetch({
|
|
1895
1948
|
baseUrl: ZOOM_OAUTH_API_URL,
|
|
@@ -1905,18 +1958,6 @@ function _ts_generator(thisArg, body) {
|
|
|
1905
1958
|
});
|
|
1906
1959
|
} : _factoryConfig_fetchFactory;
|
|
1907
1960
|
return function(config) {
|
|
1908
|
-
var accessTokenFromTokenResponse = function accessTokenFromTokenResponse(result) {
|
|
1909
|
-
var createdAt = Date.now();
|
|
1910
|
-
var access_token = result.access_token, api_url = result.api_url, scope = result.scope, expires_in = result.expires_in;
|
|
1911
|
-
var accessToken = {
|
|
1912
|
-
accessToken: access_token,
|
|
1913
|
-
apiDomain: api_url,
|
|
1914
|
-
expiresIn: expires_in,
|
|
1915
|
-
expiresAt: new Date(createdAt + expires_in * util.MS_IN_SECOND),
|
|
1916
|
-
scope: scope
|
|
1917
|
-
};
|
|
1918
|
-
return accessToken;
|
|
1919
|
-
};
|
|
1920
1961
|
if (!config.clientId) {
|
|
1921
1962
|
throw new Error('ZoomOAuthConfig missing clientId.');
|
|
1922
1963
|
} else if (!config.clientSecret) {
|
|
@@ -1929,62 +1970,73 @@ function _ts_generator(thisArg, body) {
|
|
|
1929
1970
|
var fetchJson = fetch.fetchJsonFunction(fetch$1, {
|
|
1930
1971
|
handleFetchJsonParseErrorFunction: fetch.returnNullHandleFetchJsonParseErrorFunction
|
|
1931
1972
|
});
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1973
|
+
// MARK: Access Token
|
|
1974
|
+
// both grants are Basic-authed with the SAME client pair (see zoomOAuthApiFetchJsonInput), and the
|
|
1975
|
+
// guards above already require it — so unlike Cal.com there is no credential this context cannot
|
|
1976
|
+
// exchange. All a credential selects is which grant is used
|
|
1977
|
+
var makeAccessTokenFactory = function makeAccessTokenFactory(credential) {
|
|
1978
|
+
var tokenRefresher;
|
|
1979
|
+
if (isZoomRefreshTokenCredential(credential)) {
|
|
1980
|
+
var refreshToken = credential.refreshToken;
|
|
1981
|
+
tokenRefresher = function tokenRefresher() {
|
|
1982
|
+
return _async_to_generator(function() {
|
|
1983
|
+
return _ts_generator(this, function(_state) {
|
|
1984
|
+
switch(_state.label){
|
|
1985
|
+
case 0:
|
|
1986
|
+
return [
|
|
1987
|
+
4,
|
|
1988
|
+
userAccessToken(oauthContext)({
|
|
1989
|
+
refreshToken: refreshToken
|
|
1990
|
+
})
|
|
1991
|
+
];
|
|
1992
|
+
case 1:
|
|
1993
|
+
return [
|
|
1994
|
+
2,
|
|
1995
|
+
zoomAccessTokenFromTokenResponse.apply(void 0, [
|
|
1996
|
+
_state.sent()
|
|
1997
|
+
])
|
|
1998
|
+
];
|
|
1999
|
+
}
|
|
2000
|
+
});
|
|
2001
|
+
})();
|
|
2002
|
+
};
|
|
2003
|
+
} else {
|
|
2004
|
+
var accountId = credential.accountId;
|
|
2005
|
+
tokenRefresher = function tokenRefresher() {
|
|
2006
|
+
return _async_to_generator(function() {
|
|
2007
|
+
return _ts_generator(this, function(_state) {
|
|
2008
|
+
switch(_state.label){
|
|
2009
|
+
case 0:
|
|
2010
|
+
return [
|
|
2011
|
+
4,
|
|
2012
|
+
serverAccessToken(oauthContext)({
|
|
2013
|
+
accountId: accountId
|
|
2014
|
+
})
|
|
2015
|
+
];
|
|
2016
|
+
case 1:
|
|
2017
|
+
return [
|
|
2018
|
+
2,
|
|
2019
|
+
zoomAccessTokenFromTokenResponse.apply(void 0, [
|
|
2020
|
+
_state.sent()
|
|
2021
|
+
])
|
|
2022
|
+
];
|
|
2023
|
+
}
|
|
2024
|
+
});
|
|
2025
|
+
})();
|
|
2026
|
+
};
|
|
2027
|
+
}
|
|
1978
2028
|
return zoomOAuthZoomAccessTokenFactory({
|
|
1979
|
-
tokenRefresher:
|
|
1980
|
-
accessTokenCache:
|
|
2029
|
+
tokenRefresher: tokenRefresher,
|
|
2030
|
+
accessTokenCache: credential.accessTokenCache
|
|
1981
2031
|
});
|
|
1982
2032
|
};
|
|
2033
|
+
// built once, so the account credential's in-memory tier is shared across the whole context
|
|
2034
|
+
var loadAccessToken = makeAccessTokenFactory(zoomOAuthConfigAccountCredential(config));
|
|
1983
2035
|
var oauthContext = {
|
|
1984
2036
|
fetch: fetch$1,
|
|
1985
2037
|
fetchJson: fetchJson,
|
|
1986
2038
|
loadAccessToken: loadAccessToken,
|
|
1987
|
-
|
|
2039
|
+
makeAccessTokenFactory: makeAccessTokenFactory,
|
|
1988
2040
|
config: config
|
|
1989
2041
|
};
|
|
1990
2042
|
var zoomOAuth = {
|
|
@@ -2125,6 +2177,7 @@ exports.getUser = getUser;
|
|
|
2125
2177
|
exports.handleZoomErrorFetch = handleZoomErrorFetch;
|
|
2126
2178
|
exports.handleZoomErrorFetchFactory = handleZoomErrorFetchFactory;
|
|
2127
2179
|
exports.handleZoomOAuthErrorFetch = handleZoomOAuthErrorFetch;
|
|
2180
|
+
exports.isZoomRefreshTokenCredential = isZoomRefreshTokenCredential;
|
|
2128
2181
|
exports.listMeetingsForUser = listMeetingsForUser;
|
|
2129
2182
|
exports.listMeetingsForUserPageFactory = listMeetingsForUserPageFactory;
|
|
2130
2183
|
exports.listUsers = listUsers;
|
|
@@ -2143,10 +2196,12 @@ exports.serverAccessToken = serverAccessToken;
|
|
|
2143
2196
|
exports.silenceZoomErrorWithCodesFunction = silenceZoomErrorWithCodesFunction;
|
|
2144
2197
|
exports.updateMeeting = updateMeeting;
|
|
2145
2198
|
exports.userAccessToken = userAccessToken;
|
|
2199
|
+
exports.zoomAccessTokenFromTokenResponse = zoomAccessTokenFromTokenResponse;
|
|
2146
2200
|
exports.zoomAccessTokenStringFactory = zoomAccessTokenStringFactory;
|
|
2147
2201
|
exports.zoomFactory = zoomFactory;
|
|
2148
2202
|
exports.zoomFetchPageFactory = zoomFetchPageFactory;
|
|
2149
2203
|
exports.zoomOAuthApiFetchJsonInput = zoomOAuthApiFetchJsonInput;
|
|
2204
|
+
exports.zoomOAuthConfigAccountCredential = zoomOAuthConfigAccountCredential;
|
|
2150
2205
|
exports.zoomOAuthFactory = zoomOAuthFactory;
|
|
2151
2206
|
exports.zoomOAuthServerBasicAuthorizationHeaderValue = zoomOAuthServerBasicAuthorizationHeaderValue;
|
|
2152
2207
|
exports.zoomOAuthZoomAccessTokenFactory = zoomOAuthZoomAccessTokenFactory;
|
package/index.esm.js
CHANGED
|
@@ -1654,14 +1654,17 @@ function _ts_generator$1(thisArg, body) {
|
|
|
1654
1654
|
});
|
|
1655
1655
|
// MARK: Make User Context
|
|
1656
1656
|
var makeUserContext = function makeUserContext(input) {
|
|
1657
|
-
var userAccessTokenFactory = oauthContext.
|
|
1657
|
+
var userAccessTokenFactory = oauthContext.makeAccessTokenFactory({
|
|
1658
1658
|
refreshToken: input.refreshToken,
|
|
1659
|
-
|
|
1659
|
+
accessTokenCache: input.accessTokenCache
|
|
1660
1660
|
});
|
|
1661
1661
|
var userAccessTokenStringFactory = zoomAccessTokenStringFactory(userAccessTokenFactory);
|
|
1662
|
-
var
|
|
1662
|
+
var userBaseFetch = fetchFactory({
|
|
1663
1663
|
zoomAccessTokenStringFactory: userAccessTokenStringFactory
|
|
1664
1664
|
});
|
|
1665
|
+
// wrapped for the same reason the server fetch is: without it a per-user call's error skips
|
|
1666
|
+
// Zoom's parsed error family and its rate-limit header handling
|
|
1667
|
+
var userFetch = handleZoomErrorFetch(userBaseFetch, logZoomServerErrorFunction);
|
|
1665
1668
|
var userFetchJson = fetchJsonFunction(userFetch, {
|
|
1666
1669
|
handleFetchJsonParseErrorFunction: returnNullHandleFetchJsonParseErrorFunction
|
|
1667
1670
|
});
|
|
@@ -1750,6 +1753,36 @@ function _ts_generator$1(thisArg, body) {
|
|
|
1750
1753
|
/**
|
|
1751
1754
|
* The Zoom OAuth API URL for the US datacenter.
|
|
1752
1755
|
*/ var ZOOM_OAUTH_API_URL = 'https://zoom.us/oauth';
|
|
1756
|
+
/**
|
|
1757
|
+
* Returns whether the credential is a {@link ZoomRefreshTokenCredential}.
|
|
1758
|
+
*
|
|
1759
|
+
* Checked before the account arm on purpose: `accountId` is also ambient on {@link ZoomOAuthConfig},
|
|
1760
|
+
* so a credential carrying both reads as a user credential that picked up an accountId — never the
|
|
1761
|
+
* reverse.
|
|
1762
|
+
*
|
|
1763
|
+
* @param credential - The credential to check.
|
|
1764
|
+
* @returns True when the credential carries a refresh token.
|
|
1765
|
+
*
|
|
1766
|
+
* @__NO_SIDE_EFFECTS__
|
|
1767
|
+
*/ function isZoomRefreshTokenCredential(credential) {
|
|
1768
|
+
return credential.refreshToken != null;
|
|
1769
|
+
}
|
|
1770
|
+
/**
|
|
1771
|
+
* The ambient credential a {@link ZoomOAuthConfig} authenticates the app's own calls with.
|
|
1772
|
+
*
|
|
1773
|
+
* Zoom's ambient credential is fully determined by the config — there is no choice to configure, so
|
|
1774
|
+
* it is derived here rather than being a settable field.
|
|
1775
|
+
*
|
|
1776
|
+
* @param config - The OAuth configuration.
|
|
1777
|
+
* @returns The account credential for that configuration.
|
|
1778
|
+
*
|
|
1779
|
+
* @__NO_SIDE_EFFECTS__
|
|
1780
|
+
*/ function zoomOAuthConfigAccountCredential(config) {
|
|
1781
|
+
return {
|
|
1782
|
+
accountId: config.accountId,
|
|
1783
|
+
accessTokenCache: config.accessTokenCache
|
|
1784
|
+
};
|
|
1785
|
+
}
|
|
1753
1786
|
|
|
1754
1787
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
1755
1788
|
try {
|
|
@@ -1879,6 +1912,25 @@ function _ts_generator(thisArg, body) {
|
|
|
1879
1912
|
};
|
|
1880
1913
|
}
|
|
1881
1914
|
}
|
|
1915
|
+
/**
|
|
1916
|
+
* Maps a {@link ZoomOAuthAccessTokenResponse} to a {@link ZoomAccessToken}.
|
|
1917
|
+
*
|
|
1918
|
+
* @param response - The token response returned by the Zoom token endpoint.
|
|
1919
|
+
* @returns The equivalent ZoomAccessToken, with `expiresAt` resolved against the current time.
|
|
1920
|
+
*
|
|
1921
|
+
* @__NO_SIDE_EFFECTS__
|
|
1922
|
+
*/ function zoomAccessTokenFromTokenResponse(response) {
|
|
1923
|
+
var createdAt = Date.now();
|
|
1924
|
+
var access_token = response.access_token, api_url = response.api_url, scope = response.scope, expires_in = response.expires_in;
|
|
1925
|
+
var accessToken = {
|
|
1926
|
+
accessToken: access_token,
|
|
1927
|
+
apiDomain: api_url,
|
|
1928
|
+
expiresIn: expires_in,
|
|
1929
|
+
expiresAt: new Date(createdAt + expires_in * MS_IN_SECOND),
|
|
1930
|
+
scope: scope
|
|
1931
|
+
};
|
|
1932
|
+
return accessToken;
|
|
1933
|
+
}
|
|
1882
1934
|
/**
|
|
1883
1935
|
* Creates a ZoomOAuth instance factory from the given configuration.
|
|
1884
1936
|
*
|
|
@@ -1887,7 +1939,8 @@ function _ts_generator(thisArg, body) {
|
|
|
1887
1939
|
*
|
|
1888
1940
|
* @__NO_SIDE_EFFECTS__
|
|
1889
1941
|
*/ function zoomOAuthFactory(factoryConfig) {
|
|
1890
|
-
var
|
|
1942
|
+
var _factoryConfig_fetchHandler;
|
|
1943
|
+
var fetchHandler = (_factoryConfig_fetchHandler = factoryConfig.fetchHandler) !== null && _factoryConfig_fetchHandler !== void 0 ? _factoryConfig_fetchHandler : zoomRateLimitedFetchHandler();
|
|
1891
1944
|
var logZoomServerErrorFunction = factoryConfig.logZoomServerErrorFunction, _factoryConfig_fetchFactory = factoryConfig.fetchFactory, fetchFactory = _factoryConfig_fetchFactory === void 0 ? function() {
|
|
1892
1945
|
return fetchApiFetchService.makeFetch({
|
|
1893
1946
|
baseUrl: ZOOM_OAUTH_API_URL,
|
|
@@ -1903,18 +1956,6 @@ function _ts_generator(thisArg, body) {
|
|
|
1903
1956
|
});
|
|
1904
1957
|
} : _factoryConfig_fetchFactory;
|
|
1905
1958
|
return function(config) {
|
|
1906
|
-
var accessTokenFromTokenResponse = function accessTokenFromTokenResponse(result) {
|
|
1907
|
-
var createdAt = Date.now();
|
|
1908
|
-
var access_token = result.access_token, api_url = result.api_url, scope = result.scope, expires_in = result.expires_in;
|
|
1909
|
-
var accessToken = {
|
|
1910
|
-
accessToken: access_token,
|
|
1911
|
-
apiDomain: api_url,
|
|
1912
|
-
expiresIn: expires_in,
|
|
1913
|
-
expiresAt: new Date(createdAt + expires_in * MS_IN_SECOND),
|
|
1914
|
-
scope: scope
|
|
1915
|
-
};
|
|
1916
|
-
return accessToken;
|
|
1917
|
-
};
|
|
1918
1959
|
if (!config.clientId) {
|
|
1919
1960
|
throw new Error('ZoomOAuthConfig missing clientId.');
|
|
1920
1961
|
} else if (!config.clientSecret) {
|
|
@@ -1927,62 +1968,73 @@ function _ts_generator(thisArg, body) {
|
|
|
1927
1968
|
var fetchJson = fetchJsonFunction(fetch, {
|
|
1928
1969
|
handleFetchJsonParseErrorFunction: returnNullHandleFetchJsonParseErrorFunction
|
|
1929
1970
|
});
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1971
|
+
// MARK: Access Token
|
|
1972
|
+
// both grants are Basic-authed with the SAME client pair (see zoomOAuthApiFetchJsonInput), and the
|
|
1973
|
+
// guards above already require it — so unlike Cal.com there is no credential this context cannot
|
|
1974
|
+
// exchange. All a credential selects is which grant is used
|
|
1975
|
+
var makeAccessTokenFactory = function makeAccessTokenFactory(credential) {
|
|
1976
|
+
var tokenRefresher;
|
|
1977
|
+
if (isZoomRefreshTokenCredential(credential)) {
|
|
1978
|
+
var refreshToken = credential.refreshToken;
|
|
1979
|
+
tokenRefresher = function tokenRefresher() {
|
|
1980
|
+
return _async_to_generator(function() {
|
|
1981
|
+
return _ts_generator(this, function(_state) {
|
|
1982
|
+
switch(_state.label){
|
|
1983
|
+
case 0:
|
|
1984
|
+
return [
|
|
1985
|
+
4,
|
|
1986
|
+
userAccessToken(oauthContext)({
|
|
1987
|
+
refreshToken: refreshToken
|
|
1988
|
+
})
|
|
1989
|
+
];
|
|
1990
|
+
case 1:
|
|
1991
|
+
return [
|
|
1992
|
+
2,
|
|
1993
|
+
zoomAccessTokenFromTokenResponse.apply(void 0, [
|
|
1994
|
+
_state.sent()
|
|
1995
|
+
])
|
|
1996
|
+
];
|
|
1997
|
+
}
|
|
1998
|
+
});
|
|
1999
|
+
})();
|
|
2000
|
+
};
|
|
2001
|
+
} else {
|
|
2002
|
+
var accountId = credential.accountId;
|
|
2003
|
+
tokenRefresher = function tokenRefresher() {
|
|
2004
|
+
return _async_to_generator(function() {
|
|
2005
|
+
return _ts_generator(this, function(_state) {
|
|
2006
|
+
switch(_state.label){
|
|
2007
|
+
case 0:
|
|
2008
|
+
return [
|
|
2009
|
+
4,
|
|
2010
|
+
serverAccessToken(oauthContext)({
|
|
2011
|
+
accountId: accountId
|
|
2012
|
+
})
|
|
2013
|
+
];
|
|
2014
|
+
case 1:
|
|
2015
|
+
return [
|
|
2016
|
+
2,
|
|
2017
|
+
zoomAccessTokenFromTokenResponse.apply(void 0, [
|
|
2018
|
+
_state.sent()
|
|
2019
|
+
])
|
|
2020
|
+
];
|
|
2021
|
+
}
|
|
2022
|
+
});
|
|
2023
|
+
})();
|
|
2024
|
+
};
|
|
2025
|
+
}
|
|
1976
2026
|
return zoomOAuthZoomAccessTokenFactory({
|
|
1977
|
-
tokenRefresher:
|
|
1978
|
-
accessTokenCache:
|
|
2027
|
+
tokenRefresher: tokenRefresher,
|
|
2028
|
+
accessTokenCache: credential.accessTokenCache
|
|
1979
2029
|
});
|
|
1980
2030
|
};
|
|
2031
|
+
// built once, so the account credential's in-memory tier is shared across the whole context
|
|
2032
|
+
var loadAccessToken = makeAccessTokenFactory(zoomOAuthConfigAccountCredential(config));
|
|
1981
2033
|
var oauthContext = {
|
|
1982
2034
|
fetch: fetch,
|
|
1983
2035
|
fetchJson: fetchJson,
|
|
1984
2036
|
loadAccessToken: loadAccessToken,
|
|
1985
|
-
|
|
2037
|
+
makeAccessTokenFactory: makeAccessTokenFactory,
|
|
1986
2038
|
config: config
|
|
1987
2039
|
};
|
|
1988
2040
|
var zoomOAuth = {
|
|
@@ -2092,4 +2144,4 @@ function _ts_generator(thisArg, body) {
|
|
|
2092
2144
|
};
|
|
2093
2145
|
}
|
|
2094
2146
|
|
|
2095
|
-
export { DEFAULT_ZOOM_API_RATE_LIMIT, DEFAULT_ZOOM_API_RATE_LIMIT_RESET_PERIOD, DEFAULT_ZOOM_RATE_LIMITED_TOO_MANY_REQUESTS_LOG_FUNCTION, DEFAULT_ZOOM_RATE_LIMITED_TOO_MANY_REQUETS_LOG_FUNCTION, DELETE_MEETING_DOES_NOT_EXIST_ERROR_CODE, ZOOM_ACCOUNTS_INVALID_GRANT_ERROR_CODE, ZOOM_API_URL, ZOOM_OAUTH_API_URL, ZOOM_RATE_LIMIT_CATEGORY_HEADER, ZOOM_RATE_LIMIT_LIMIT_HEADER, ZOOM_RATE_LIMIT_REMAINING_HEADER, ZOOM_RATE_LIMIT_RETRY_AFTER_HEADER, ZOOM_RATE_LIMIT_TYPE_HEADER, ZOOM_SUCCESS_CODE, ZOOM_TOO_MANY_REQUESTS_ERROR_CODE, ZOOM_TOO_MANY_REQUESTS_HTTP_STATUS_CODE, ZoomApprovalType, ZoomMeetingType, ZoomMonthlyWeek, ZoomMonthlyWeekDay, ZoomOAuthAccessTokenError, ZoomOAuthAuthFailureError, ZoomRecurrenceType, ZoomRegistrationType, ZoomServerError, ZoomServerFetchResponseError, ZoomTooManyRequestsError, ZoomUserType, createMeetingForUser, deleteMeeting, getMeeting, getPastMeeting, getPastMeetingParticipants, getPastMeetingParticipantsPageFactory, getUser, handleZoomErrorFetch, handleZoomErrorFetchFactory, handleZoomOAuthErrorFetch, listMeetingsForUser, listMeetingsForUserPageFactory, listUsers, listUsersPageFactory, logZoomErrorToConsole, logZoomOAuthErrorToConsole, logZoomServerErrorFunction, mapToZoomPageResult, omitSilenceZoomErrorKeys, parseZoomApiError, parseZoomApiServerErrorResponseData, parseZoomOAuthError, parseZoomOAuthServerErrorResponseData, parseZoomServerErrorData, serverAccessToken, silenceZoomErrorWithCodesFunction, updateMeeting, userAccessToken, zoomAccessTokenStringFactory, zoomFactory, zoomFetchPageFactory, zoomOAuthApiFetchJsonInput, zoomOAuthFactory, zoomOAuthServerBasicAuthorizationHeaderValue, zoomOAuthZoomAccessTokenFactory, zoomRateLimitHeaderDetails, zoomRateLimitedFetchHandler };
|
|
2147
|
+
export { DEFAULT_ZOOM_API_RATE_LIMIT, DEFAULT_ZOOM_API_RATE_LIMIT_RESET_PERIOD, DEFAULT_ZOOM_RATE_LIMITED_TOO_MANY_REQUESTS_LOG_FUNCTION, DEFAULT_ZOOM_RATE_LIMITED_TOO_MANY_REQUETS_LOG_FUNCTION, DELETE_MEETING_DOES_NOT_EXIST_ERROR_CODE, ZOOM_ACCOUNTS_INVALID_GRANT_ERROR_CODE, ZOOM_API_URL, ZOOM_OAUTH_API_URL, ZOOM_RATE_LIMIT_CATEGORY_HEADER, ZOOM_RATE_LIMIT_LIMIT_HEADER, ZOOM_RATE_LIMIT_REMAINING_HEADER, ZOOM_RATE_LIMIT_RETRY_AFTER_HEADER, ZOOM_RATE_LIMIT_TYPE_HEADER, ZOOM_SUCCESS_CODE, ZOOM_TOO_MANY_REQUESTS_ERROR_CODE, ZOOM_TOO_MANY_REQUESTS_HTTP_STATUS_CODE, ZoomApprovalType, ZoomMeetingType, ZoomMonthlyWeek, ZoomMonthlyWeekDay, ZoomOAuthAccessTokenError, ZoomOAuthAuthFailureError, ZoomRecurrenceType, ZoomRegistrationType, ZoomServerError, ZoomServerFetchResponseError, ZoomTooManyRequestsError, ZoomUserType, createMeetingForUser, deleteMeeting, getMeeting, getPastMeeting, getPastMeetingParticipants, getPastMeetingParticipantsPageFactory, getUser, handleZoomErrorFetch, handleZoomErrorFetchFactory, handleZoomOAuthErrorFetch, isZoomRefreshTokenCredential, listMeetingsForUser, listMeetingsForUserPageFactory, listUsers, listUsersPageFactory, logZoomErrorToConsole, logZoomOAuthErrorToConsole, logZoomServerErrorFunction, mapToZoomPageResult, omitSilenceZoomErrorKeys, parseZoomApiError, parseZoomApiServerErrorResponseData, parseZoomOAuthError, parseZoomOAuthServerErrorResponseData, parseZoomServerErrorData, serverAccessToken, silenceZoomErrorWithCodesFunction, updateMeeting, userAccessToken, zoomAccessTokenFromTokenResponse, zoomAccessTokenStringFactory, zoomFactory, zoomFetchPageFactory, zoomOAuthApiFetchJsonInput, zoomOAuthConfigAccountCredential, zoomOAuthFactory, zoomOAuthServerBasicAuthorizationHeaderValue, zoomOAuthZoomAccessTokenFactory, zoomRateLimitHeaderDetails, zoomRateLimitedFetchHandler };
|
package/nestjs/index.cjs.js
CHANGED
|
@@ -107,7 +107,6 @@ function _define_property$8(obj, key, value) {
|
|
|
107
107
|
var clientSecret = configService.getOrThrow(clientSecretKey);
|
|
108
108
|
var config = {
|
|
109
109
|
zoomOAuth: {
|
|
110
|
-
authEntityType: 'account',
|
|
111
110
|
accountId: accountId,
|
|
112
111
|
clientId: clientId,
|
|
113
112
|
clientSecret: clientSecret
|
|
@@ -216,7 +215,7 @@ function _non_iterable_rest() {
|
|
|
216
215
|
function _non_iterable_spread$2() {
|
|
217
216
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
218
217
|
}
|
|
219
|
-
function _object_spread$
|
|
218
|
+
function _object_spread$2(target) {
|
|
220
219
|
for(var i = 1; i < arguments.length; i++){
|
|
221
220
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
222
221
|
var ownKeys = Object.keys(source);
|
|
@@ -608,7 +607,7 @@ var DEFAULT_FILE_ZOOM_ACCOUNTS_ACCESS_TOKEN_CACHE_SERVICE_PATH = '.tmp/zoom-acce
|
|
|
608
607
|
} else {
|
|
609
608
|
var rawExpiresAt = token.expiresAt;
|
|
610
609
|
var expiresAt = rawExpiresAt != null && !_instanceof(rawExpiresAt, Date) ? new Date(rawExpiresAt) : rawExpiresAt;
|
|
611
|
-
result = _object_spread_props$2(_object_spread$
|
|
610
|
+
result = _object_spread_props$2(_object_spread$2({}, token), {
|
|
612
611
|
expiresAt: expiresAt
|
|
613
612
|
});
|
|
614
613
|
}
|
|
@@ -806,21 +805,6 @@ function _define_property$6(obj, key, value) {
|
|
|
806
805
|
}
|
|
807
806
|
return obj;
|
|
808
807
|
}
|
|
809
|
-
function _object_spread$2(target) {
|
|
810
|
-
for(var i = 1; i < arguments.length; i++){
|
|
811
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
812
|
-
var ownKeys = Object.keys(source);
|
|
813
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
814
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
815
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
816
|
-
}));
|
|
817
|
-
}
|
|
818
|
-
ownKeys.forEach(function(key) {
|
|
819
|
-
_define_property$6(target, key, source[key]);
|
|
820
|
-
});
|
|
821
|
-
}
|
|
822
|
-
return target;
|
|
823
|
-
}
|
|
824
808
|
exports.ZoomOAuthApi = /*#__PURE__*/ function() {
|
|
825
809
|
function ZoomOAuthApi(config, cacheService) {
|
|
826
810
|
_class_call_check$6(this, ZoomOAuthApi);
|
|
@@ -830,10 +814,17 @@ exports.ZoomOAuthApi = /*#__PURE__*/ function() {
|
|
|
830
814
|
_define_property$6(this, "zoomOAuth", void 0);
|
|
831
815
|
this.config = config;
|
|
832
816
|
this.cacheService = cacheService;
|
|
817
|
+
var _config_zoomOAuth = config.zoomOAuth, clientId = _config_zoomOAuth.clientId, clientSecret = _config_zoomOAuth.clientSecret, accountId = _config_zoomOAuth.accountId;
|
|
833
818
|
var accessTokenCache = (_config_zoomOAuth_accessTokenCache = config.zoomOAuth.accessTokenCache) !== null && _config_zoomOAuth_accessTokenCache !== void 0 ? _config_zoomOAuth_accessTokenCache : cacheService.loadZoomAccessTokenCache();
|
|
834
|
-
|
|
819
|
+
// the fields the OAuth context needs are named rather than spread: the spread used to come AFTER
|
|
820
|
+
// `accessTokenCache`, so a present-but-undefined key on the service config would overwrite the
|
|
821
|
+
// cache just resolved from the cache service
|
|
822
|
+
this.zoomOAuth = zoom.zoomOAuthFactory((_config_factoryConfig = config.factoryConfig) !== null && _config_factoryConfig !== void 0 ? _config_factoryConfig : {})({
|
|
823
|
+
clientId: clientId,
|
|
824
|
+
clientSecret: clientSecret,
|
|
825
|
+
accountId: accountId,
|
|
835
826
|
accessTokenCache: accessTokenCache
|
|
836
|
-
}
|
|
827
|
+
});
|
|
837
828
|
}
|
|
838
829
|
_create_class$5(ZoomOAuthApi, [
|
|
839
830
|
{
|
package/nestjs/index.esm.js
CHANGED
|
@@ -105,7 +105,6 @@ function _define_property$8(obj, key, value) {
|
|
|
105
105
|
var clientSecret = configService.getOrThrow(clientSecretKey);
|
|
106
106
|
var config = {
|
|
107
107
|
zoomOAuth: {
|
|
108
|
-
authEntityType: 'account',
|
|
109
108
|
accountId: accountId,
|
|
110
109
|
clientId: clientId,
|
|
111
110
|
clientSecret: clientSecret
|
|
@@ -214,7 +213,7 @@ function _non_iterable_rest() {
|
|
|
214
213
|
function _non_iterable_spread$2() {
|
|
215
214
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
216
215
|
}
|
|
217
|
-
function _object_spread$
|
|
216
|
+
function _object_spread$2(target) {
|
|
218
217
|
for(var i = 1; i < arguments.length; i++){
|
|
219
218
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
220
219
|
var ownKeys = Object.keys(source);
|
|
@@ -606,7 +605,7 @@ var DEFAULT_FILE_ZOOM_ACCOUNTS_ACCESS_TOKEN_CACHE_SERVICE_PATH = '.tmp/zoom-acce
|
|
|
606
605
|
} else {
|
|
607
606
|
var rawExpiresAt = token.expiresAt;
|
|
608
607
|
var expiresAt = rawExpiresAt != null && !_instanceof(rawExpiresAt, Date) ? new Date(rawExpiresAt) : rawExpiresAt;
|
|
609
|
-
result = _object_spread_props$2(_object_spread$
|
|
608
|
+
result = _object_spread_props$2(_object_spread$2({}, token), {
|
|
610
609
|
expiresAt: expiresAt
|
|
611
610
|
});
|
|
612
611
|
}
|
|
@@ -804,21 +803,6 @@ function _define_property$6(obj, key, value) {
|
|
|
804
803
|
}
|
|
805
804
|
return obj;
|
|
806
805
|
}
|
|
807
|
-
function _object_spread$2(target) {
|
|
808
|
-
for(var i = 1; i < arguments.length; i++){
|
|
809
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
810
|
-
var ownKeys = Object.keys(source);
|
|
811
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
812
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
813
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
814
|
-
}));
|
|
815
|
-
}
|
|
816
|
-
ownKeys.forEach(function(key) {
|
|
817
|
-
_define_property$6(target, key, source[key]);
|
|
818
|
-
});
|
|
819
|
-
}
|
|
820
|
-
return target;
|
|
821
|
-
}
|
|
822
806
|
var ZoomOAuthApi = /*#__PURE__*/ function() {
|
|
823
807
|
function ZoomOAuthApi(config, cacheService) {
|
|
824
808
|
_class_call_check$6(this, ZoomOAuthApi);
|
|
@@ -828,10 +812,17 @@ var ZoomOAuthApi = /*#__PURE__*/ function() {
|
|
|
828
812
|
_define_property$6(this, "zoomOAuth", void 0);
|
|
829
813
|
this.config = config;
|
|
830
814
|
this.cacheService = cacheService;
|
|
815
|
+
var _config_zoomOAuth = config.zoomOAuth, clientId = _config_zoomOAuth.clientId, clientSecret = _config_zoomOAuth.clientSecret, accountId = _config_zoomOAuth.accountId;
|
|
831
816
|
var accessTokenCache = (_config_zoomOAuth_accessTokenCache = config.zoomOAuth.accessTokenCache) !== null && _config_zoomOAuth_accessTokenCache !== void 0 ? _config_zoomOAuth_accessTokenCache : cacheService.loadZoomAccessTokenCache();
|
|
832
|
-
|
|
817
|
+
// the fields the OAuth context needs are named rather than spread: the spread used to come AFTER
|
|
818
|
+
// `accessTokenCache`, so a present-but-undefined key on the service config would overwrite the
|
|
819
|
+
// cache just resolved from the cache service
|
|
820
|
+
this.zoomOAuth = zoomOAuthFactory((_config_factoryConfig = config.factoryConfig) !== null && _config_factoryConfig !== void 0 ? _config_factoryConfig : {})({
|
|
821
|
+
clientId: clientId,
|
|
822
|
+
clientSecret: clientSecret,
|
|
823
|
+
accountId: accountId,
|
|
833
824
|
accessTokenCache: accessTokenCache
|
|
834
|
-
}
|
|
825
|
+
});
|
|
835
826
|
}
|
|
836
827
|
_create_class$5(ZoomOAuthApi, [
|
|
837
828
|
{
|
package/nestjs/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/zoom/nestjs",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.34.0",
|
|
4
4
|
"peerDependencies": {
|
|
5
|
-
"@dereekb/nestjs": "13.
|
|
6
|
-
"@dereekb/rxjs": "13.
|
|
7
|
-
"@dereekb/util": "13.
|
|
8
|
-
"@dereekb/zoom": "13.
|
|
5
|
+
"@dereekb/nestjs": "13.34.0",
|
|
6
|
+
"@dereekb/rxjs": "13.34.0",
|
|
7
|
+
"@dereekb/util": "13.34.0",
|
|
8
|
+
"@dereekb/zoom": "13.34.0",
|
|
9
9
|
"@nestjs/common": "^11.1.19",
|
|
10
10
|
"@nestjs/config": "^4.0.4",
|
|
11
11
|
"express": "^5.2.1"
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { type ZoomOAuthConfig, type ZoomOAuthFactoryConfig } from '@dereekb/zoom';
|
|
2
2
|
import { type ConfigService } from '@nestjs/config';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
/**
|
|
4
|
+
* The environment-facing Zoom OAuth configuration.
|
|
5
|
+
*
|
|
6
|
+
* Stays flat, mirroring the ZOOM_* variables it is read from. Previously omitted `userRefreshToken`
|
|
7
|
+
* and `type`, neither of which exists on {@link ZoomOAuthConfig} — a no-op that would have silently
|
|
8
|
+
* stripped either key had one ever been added.
|
|
9
|
+
*/
|
|
10
|
+
export type ZoomOAuthServiceApiConfig = ZoomOAuthConfig;
|
|
6
11
|
/**
|
|
7
12
|
* Configuration for ZoomService
|
|
8
13
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/zoom",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.34.0",
|
|
4
4
|
"exports": {
|
|
5
5
|
"./nestjs": {
|
|
6
6
|
"module": "./nestjs/index.esm.js",
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
|
-
"@dereekb/nestjs": "13.
|
|
21
|
-
"@dereekb/rxjs": "13.
|
|
22
|
-
"@dereekb/util": "13.
|
|
20
|
+
"@dereekb/nestjs": "13.34.0",
|
|
21
|
+
"@dereekb/rxjs": "13.34.0",
|
|
22
|
+
"@dereekb/util": "13.34.0",
|
|
23
23
|
"@nestjs/common": "^11.1.19",
|
|
24
24
|
"@nestjs/config": "^4.0.4",
|
|
25
25
|
"express": "^5.2.1",
|
|
@@ -24,19 +24,84 @@ export interface ZoomOAuthConfig extends ZoomAuthClientIdAndSecretPair, ZoomAcco
|
|
|
24
24
|
export interface ZoomOAuthFetchFactoryParams {
|
|
25
25
|
}
|
|
26
26
|
export type ZoomOAuthFetchFactory = FactoryWithInput<ConfiguredFetch, ZoomOAuthFetchFactoryParams>;
|
|
27
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Credential for the app's own (account-level) calls.
|
|
29
|
+
*
|
|
30
|
+
* Exchanged as `grant_type=account_credentials`, authenticated with the client pair on
|
|
31
|
+
* {@link ZoomOAuthConfig}. Unlike Cal.com's api-key equivalent the resulting token DOES expire, so
|
|
32
|
+
* this arm carries its own cache.
|
|
33
|
+
*/
|
|
34
|
+
export interface ZoomAccountCredential extends ZoomAccountIdRef {
|
|
35
|
+
readonly accessTokenCache?: Maybe<ZoomAccessTokenCache>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Credential for acting as a specific user.
|
|
39
|
+
*
|
|
40
|
+
* Exchanged as `grant_type=refresh_token`, authenticated with the same client pair.
|
|
41
|
+
*/
|
|
42
|
+
export interface ZoomRefreshTokenCredential {
|
|
28
43
|
readonly refreshToken: ZoomRefreshToken;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Cache for THIS user's access token.
|
|
46
|
+
*
|
|
47
|
+
* Must be scoped to the user that owns the refresh token — handing it the account-level cache
|
|
48
|
+
* would let a user token and the app's own token overwrite each other.
|
|
49
|
+
*/
|
|
50
|
+
readonly accessTokenCache?: Maybe<ZoomAccessTokenCache>;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* A credential Zoom calls can be made with.
|
|
54
|
+
*
|
|
55
|
+
* One union for the app's own calls and for any per-user one; the credential selects the grant.
|
|
56
|
+
* The client pair authenticates BOTH exchanges and so lives on the config rather than here.
|
|
57
|
+
*/
|
|
58
|
+
export type ZoomAuthCredential = ZoomAccountCredential | ZoomRefreshTokenCredential;
|
|
59
|
+
/**
|
|
60
|
+
* Returns whether the credential is a {@link ZoomRefreshTokenCredential}.
|
|
61
|
+
*
|
|
62
|
+
* Checked before the account arm on purpose: `accountId` is also ambient on {@link ZoomOAuthConfig},
|
|
63
|
+
* so a credential carrying both reads as a user credential that picked up an accountId — never the
|
|
64
|
+
* reverse.
|
|
65
|
+
*
|
|
66
|
+
* @param credential - The credential to check.
|
|
67
|
+
* @returns True when the credential carries a refresh token.
|
|
68
|
+
*
|
|
69
|
+
* @__NO_SIDE_EFFECTS__
|
|
70
|
+
*/
|
|
71
|
+
export declare function isZoomRefreshTokenCredential(credential: ZoomAuthCredential): credential is ZoomRefreshTokenCredential;
|
|
72
|
+
/**
|
|
73
|
+
* The ambient credential a {@link ZoomOAuthConfig} authenticates the app's own calls with.
|
|
74
|
+
*
|
|
75
|
+
* Zoom's ambient credential is fully determined by the config — there is no choice to configure, so
|
|
76
|
+
* it is derived here rather than being a settable field.
|
|
77
|
+
*
|
|
78
|
+
* @param config - The OAuth configuration.
|
|
79
|
+
* @returns The account credential for that configuration.
|
|
80
|
+
*
|
|
81
|
+
* @__NO_SIDE_EFFECTS__
|
|
82
|
+
*/
|
|
83
|
+
export declare function zoomOAuthConfigAccountCredential(config: ZoomOAuthConfig): ZoomAccountCredential;
|
|
84
|
+
export type ZoomOAuthMakeAccessTokenFactory = FactoryWithRequiredInput<ZoomAccessTokenFactory, ZoomAuthCredential>;
|
|
32
85
|
/**
|
|
33
86
|
* Context used for performing fetch() and fetchJson() calls with a configured fetch instance.
|
|
34
87
|
*/
|
|
35
88
|
export interface ZoomOAuthContext {
|
|
36
89
|
readonly fetch: ConfiguredFetch;
|
|
37
90
|
readonly fetchJson: FetchJsonFunction;
|
|
91
|
+
/**
|
|
92
|
+
* Resolves the access token for the app's own calls.
|
|
93
|
+
*
|
|
94
|
+
* `makeAccessTokenFactory(zoomOAuthConfigAccountCredential(config))`, built once at construction so
|
|
95
|
+
* its in-memory token tier is shared across the whole context.
|
|
96
|
+
*/
|
|
38
97
|
readonly loadAccessToken: ZoomAccessTokenFactory;
|
|
39
|
-
|
|
98
|
+
/**
|
|
99
|
+
* Builds an access token factory for one credential.
|
|
100
|
+
*
|
|
101
|
+
* Each returned factory owns its own cache tier, so refreshing one credential never overwrites
|
|
102
|
+
* another's token.
|
|
103
|
+
*/
|
|
104
|
+
readonly makeAccessTokenFactory: ZoomOAuthMakeAccessTokenFactory;
|
|
40
105
|
readonly config: ZoomOAuthConfig;
|
|
41
106
|
}
|
|
42
107
|
export interface ZoomOAuthContextRef {
|
|
@@ -46,7 +111,3 @@ export interface ZoomOAuthContextRef {
|
|
|
46
111
|
* @deprecated use ZoomOAuthFetchFactoryParams instead.
|
|
47
112
|
*/
|
|
48
113
|
export type ZoomOAuthFetchFactoryInput = ZoomOAuthFetchFactoryParams;
|
|
49
|
-
/**
|
|
50
|
-
* @deprecated use ZoomOAuthMakeUserAccessTokenFactoryParams instead.
|
|
51
|
-
*/
|
|
52
|
-
export type ZoomOAuthMakeUserAccessTokenFactoryInput = ZoomOAuthMakeUserAccessTokenFactoryParams;
|
|
@@ -1,13 +1,30 @@
|
|
|
1
|
+
import { type FetchHandler } from '@dereekb/util/fetch';
|
|
1
2
|
import { type ZoomOAuthConfig, type ZoomOAuthContextRef, type ZoomOAuthFetchFactory } from './oauth.config';
|
|
2
3
|
import { type LogZoomServerErrorFunction } from '../zoom.error.api';
|
|
3
|
-
import { type ZoomAccessTokenCache, type ZoomAccessTokenFactory, type ZoomAccessTokenRefresher } from './oauth';
|
|
4
|
+
import { type ZoomAccessToken, type ZoomAccessTokenCache, type ZoomAccessTokenFactory, type ZoomAccessTokenRefresher } from './oauth';
|
|
4
5
|
import { type Maybe, type Milliseconds } from '@dereekb/util';
|
|
6
|
+
import { type ZoomOAuthAccessTokenResponse } from './oauth.api';
|
|
5
7
|
export type ZoomOAuth = ZoomOAuthContextRef;
|
|
8
|
+
/**
|
|
9
|
+
* Maps a {@link ZoomOAuthAccessTokenResponse} to a {@link ZoomAccessToken}.
|
|
10
|
+
*
|
|
11
|
+
* @param response - The token response returned by the Zoom token endpoint.
|
|
12
|
+
* @returns The equivalent ZoomAccessToken, with `expiresAt` resolved against the current time.
|
|
13
|
+
*
|
|
14
|
+
* @__NO_SIDE_EFFECTS__
|
|
15
|
+
*/
|
|
16
|
+
export declare function zoomAccessTokenFromTokenResponse(response: ZoomOAuthAccessTokenResponse): ZoomAccessToken;
|
|
6
17
|
export interface ZoomOAuthFactoryConfig {
|
|
7
18
|
/**
|
|
8
19
|
* Creates a new fetch instance to use when making calls.
|
|
9
20
|
*/
|
|
10
21
|
readonly fetchFactory?: ZoomOAuthFetchFactory;
|
|
22
|
+
/**
|
|
23
|
+
* Custom FetchHandler to use with the default fetchFactory.
|
|
24
|
+
*
|
|
25
|
+
* Defaults to a {@link zoomRateLimitedFetchHandler}. Ignored when a `fetchFactory` is provided.
|
|
26
|
+
*/
|
|
27
|
+
readonly fetchHandler?: Maybe<FetchHandler>;
|
|
11
28
|
/**
|
|
12
29
|
* Custom log error function.
|
|
13
30
|
*/
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { type FactoryWithInput, type FactoryWithRequiredInput
|
|
1
|
+
import { type FactoryWithInput, type FactoryWithRequiredInput } from '@dereekb/util';
|
|
2
2
|
import { type ConfiguredFetch, type FetchJsonFunction } from '@dereekb/util/fetch';
|
|
3
|
-
import { type ZoomConfig
|
|
3
|
+
import { type ZoomConfig } from '../zoom.config';
|
|
4
4
|
import { type ZoomRateLimiterRef } from '../zoom.limit';
|
|
5
|
-
import { type
|
|
6
|
-
|
|
5
|
+
import { type ZoomAccessTokenStringFactory } from '../oauth/oauth';
|
|
6
|
+
import { type ZoomRefreshTokenCredential } from '../oauth/oauth.config';
|
|
7
7
|
export interface ZoomFetchFactoryParams {
|
|
8
8
|
readonly zoomAccessTokenStringFactory: ZoomAccessTokenStringFactory;
|
|
9
9
|
}
|
|
@@ -39,22 +39,14 @@ export interface ZoomServerContext extends ZoomContext {
|
|
|
39
39
|
readonly makeUserContext: ZoomUserContextFactory;
|
|
40
40
|
readonly config: ZoomConfig;
|
|
41
41
|
}
|
|
42
|
-
export interface ZoomUserContextFactoryParams {
|
|
43
|
-
/**
|
|
44
|
-
* The user's refresh token.
|
|
45
|
-
*/
|
|
46
|
-
readonly refreshToken: ZoomRefreshToken;
|
|
47
|
-
/**
|
|
48
|
-
* Optional cache to use for the user's access token.
|
|
49
|
-
*
|
|
50
|
-
* The cache should only be configured for the user that owns the refresh token.
|
|
51
|
-
*/
|
|
52
|
-
readonly accessTokenCache?: Maybe<ZoomAccessTokenCache>;
|
|
53
|
-
}
|
|
54
42
|
/**
|
|
55
|
-
* Creates a ZoomUserContext from
|
|
43
|
+
* Creates a ZoomUserContext from a user's credential.
|
|
44
|
+
*
|
|
45
|
+
* Deliberately the refresh-token arm of {@link ZoomAuthCredential} rather than the full union: a
|
|
46
|
+
* user context acts as a connected user, while the account credential is the app's own identity —
|
|
47
|
+
* which is the server context's job.
|
|
56
48
|
*/
|
|
57
|
-
export type ZoomUserContextFactory = FactoryWithRequiredInput<ZoomUserContext,
|
|
49
|
+
export type ZoomUserContextFactory = FactoryWithRequiredInput<ZoomUserContext, ZoomRefreshTokenCredential>;
|
|
58
50
|
/**
|
|
59
51
|
* Context used for performing fetch requests for a specific user.
|
|
60
52
|
*/
|
|
@@ -71,7 +63,3 @@ export interface ZoomServerContextRef {
|
|
|
71
63
|
* @deprecated use ZoomFetchFactoryParams instead.
|
|
72
64
|
*/
|
|
73
65
|
export type ZoomFetchFactoryInput = ZoomFetchFactoryParams;
|
|
74
|
-
/**
|
|
75
|
-
* @deprecated use ZoomUserContextFactoryParams instead.
|
|
76
|
-
*/
|
|
77
|
-
export type ZoomUserContextFactoryInput = ZoomUserContextFactoryParams;
|