@firebase/app-check 0.6.5 → 0.7.0-20230425221647

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.
@@ -51,6 +51,22 @@ export declare function setTokenAutoRefreshEnabled(appCheckInstance: AppCheck, i
51
51
  * @public
52
52
  */
53
53
  export declare function getToken(appCheckInstance: AppCheck, forceRefresh?: boolean): Promise<AppCheckTokenResult>;
54
+ /**
55
+ * Requests a Firebase App Check token. This method should be used
56
+ * only if you need to authorize requests to a non-Firebase backend.
57
+ *
58
+ * Returns limited-use tokens that are intended for use with your
59
+ * non-Firebase backend endpoints that are protected with
60
+ * <a href="https://firebase.google.com/docs/app-check/custom-resource-backend#replay-protection">
61
+ * Replay Protection</a>. This method
62
+ * does not affect the token generation behavior of the
63
+ * #getAppCheckToken() method.
64
+ *
65
+ * @param appCheckInstance - The App Check service instance.
66
+ * @returns The limited use token.
67
+ * @public
68
+ */
69
+ export declare function getLimitedUseToken(appCheckInstance: AppCheck): Promise<AppCheckTokenResult>;
54
70
  /**
55
71
  * Registers a listener to changes in the token state. There can be more
56
72
  * than one listener registered at the same time for one or more
@@ -33,6 +33,11 @@ export declare function formatDummyToken(tokenErrorData: Record<string, string>)
33
33
  * In case there is an error, the token field in the result will be populated with a dummy value
34
34
  */
35
35
  export declare function getToken(appCheck: AppCheckService, forceRefresh?: boolean): Promise<AppCheckTokenResult>;
36
+ /**
37
+ * Internal API for limited use tokens. Skips all FAC state and simply calls
38
+ * the underlying provider.
39
+ */
40
+ export declare function getLimitedUseToken(appCheck: AppCheckService): Promise<AppCheckTokenResult>;
36
41
  export declare function addTokenListener(appCheck: AppCheckService, type: ListenerType, listener: AppCheckTokenListener, onError?: (error: Error) => void): void;
37
42
  export declare function removeTokenListener(app: FirebaseApp, listener: AppCheckTokenListener): void;
38
43
  export declare function notifyTokenListeners(app: FirebaseApp, token: AppCheckTokenResult): void;
package/dist/index.cjs.js CHANGED
@@ -919,6 +919,35 @@ function getToken$2(appCheck, forceRefresh) {
919
919
  });
920
920
  });
921
921
  }
922
+ /**
923
+ * Internal API for limited use tokens. Skips all FAC state and simply calls
924
+ * the underlying provider.
925
+ */
926
+ function getLimitedUseToken$1(appCheck) {
927
+ return tslib.__awaiter(this, void 0, void 0, function () {
928
+ var app, provider, debugToken, token, token;
929
+ return tslib.__generator(this, function (_a) {
930
+ switch (_a.label) {
931
+ case 0:
932
+ app = appCheck.app;
933
+ ensureActivated(app);
934
+ provider = getStateReference(app).provider;
935
+ if (!isDebugMode()) return [3 /*break*/, 3];
936
+ return [4 /*yield*/, getDebugToken()];
937
+ case 1:
938
+ debugToken = _a.sent();
939
+ return [4 /*yield*/, exchangeToken(getExchangeDebugTokenRequest(app, debugToken), appCheck.heartbeatServiceProvider)];
940
+ case 2:
941
+ token = (_a.sent()).token;
942
+ return [2 /*return*/, { token: token }];
943
+ case 3: return [4 /*yield*/, provider.getToken()];
944
+ case 4:
945
+ token = (_a.sent()).token;
946
+ return [2 /*return*/, { token: token }];
947
+ }
948
+ });
949
+ });
950
+ }
922
951
  function addTokenListener(appCheck, type, listener, onError) {
923
952
  var app = appCheck.app;
924
953
  var state = getStateReference(app);
@@ -1124,7 +1153,7 @@ function internalFactory(appCheck) {
1124
1153
  }
1125
1154
 
1126
1155
  var name = "@firebase/app-check";
1127
- var version = "0.6.5";
1156
+ var version = "0.7.0-20230425221647";
1128
1157
 
1129
1158
  /**
1130
1159
  * @license
@@ -1721,6 +1750,24 @@ function getToken(appCheckInstance, forceRefresh) {
1721
1750
  });
1722
1751
  });
1723
1752
  }
1753
+ /**
1754
+ * Requests a Firebase App Check token. This method should be used
1755
+ * only if you need to authorize requests to a non-Firebase backend.
1756
+ *
1757
+ * Returns limited-use tokens that are intended for use with your
1758
+ * non-Firebase backend endpoints that are protected with
1759
+ * <a href="https://firebase.google.com/docs/app-check/custom-resource-backend#replay-protection">
1760
+ * Replay Protection</a>. This method
1761
+ * does not affect the token generation behavior of the
1762
+ * #getAppCheckToken() method.
1763
+ *
1764
+ * @param appCheckInstance - The App Check service instance.
1765
+ * @returns The limited use token.
1766
+ * @public
1767
+ */
1768
+ function getLimitedUseToken(appCheckInstance) {
1769
+ return getLimitedUseToken$1(appCheckInstance);
1770
+ }
1724
1771
  /**
1725
1772
  * Wraps `addTokenListener`/`removeTokenListener` methods in an `Observer`
1726
1773
  * pattern for public use.
@@ -1787,6 +1834,7 @@ registerAppCheck();
1787
1834
  exports.CustomProvider = CustomProvider;
1788
1835
  exports.ReCaptchaEnterpriseProvider = ReCaptchaEnterpriseProvider;
1789
1836
  exports.ReCaptchaV3Provider = ReCaptchaV3Provider;
1837
+ exports.getLimitedUseToken = getLimitedUseToken;
1790
1838
  exports.getToken = getToken;
1791
1839
  exports.initializeAppCheck = initializeAppCheck;
1792
1840
  exports.onTokenChanged = onTokenChanged;