@firebase/app-check 0.6.5 → 0.7.0-canary.4c492e04d

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.
@@ -102,6 +102,23 @@ export declare interface CustomProviderOptions {
102
102
  getToken: () => Promise<AppCheckToken>;
103
103
  }
104
104
 
105
+ /**
106
+ * Requests a Firebase App Check token. This method should be used
107
+ * only if you need to authorize requests to a non-Firebase backend.
108
+ *
109
+ * Returns limited-use tokens that are intended for use with your
110
+ * non-Firebase backend endpoints that are protected with
111
+ * <a href="https://firebase.google.com/docs/app-check/custom-resource-backend#replay-protection">
112
+ * Replay Protection</a>. This method
113
+ * does not affect the token generation behavior of the
114
+ * #getAppCheckToken() method.
115
+ *
116
+ * @param appCheckInstance - The App Check service instance.
117
+ * @returns The limited use token.
118
+ * @public
119
+ */
120
+ export declare function getLimitedUseToken(appCheckInstance: AppCheck): Promise<AppCheckTokenResult>;
121
+
105
122
  /**
106
123
  * Get the current App Check token. Attaches to the most recent
107
124
  * in-flight request if one is present. Returns null if no token
@@ -124,6 +124,23 @@ export declare interface CustomProviderOptions {
124
124
  getToken: () => Promise<AppCheckToken>;
125
125
  }
126
126
 
127
+ /**
128
+ * Requests a Firebase App Check token. This method should be used
129
+ * only if you need to authorize requests to a non-Firebase backend.
130
+ *
131
+ * Returns limited-use tokens that are intended for use with your
132
+ * non-Firebase backend endpoints that are protected with
133
+ * <a href="https://firebase.google.com/docs/app-check/custom-resource-backend#replay-protection">
134
+ * Replay Protection</a>. This method
135
+ * does not affect the token generation behavior of the
136
+ * #getAppCheckToken() method.
137
+ *
138
+ * @param appCheckInstance - The App Check service instance.
139
+ * @returns The limited use token.
140
+ * @public
141
+ */
142
+ export declare function getLimitedUseToken(appCheckInstance: AppCheck): Promise<AppCheckTokenResult>;
143
+
127
144
  /**
128
145
  * Get the current App Check token. Attaches to the most recent
129
146
  * in-flight request if one is present. Returns null if no token
@@ -915,6 +915,35 @@ function getToken$2(appCheck, forceRefresh) {
915
915
  });
916
916
  });
917
917
  }
918
+ /**
919
+ * Internal API for limited use tokens. Skips all FAC state and simply calls
920
+ * the underlying provider.
921
+ */
922
+ function getLimitedUseToken$1(appCheck) {
923
+ return __awaiter(this, void 0, void 0, function () {
924
+ var app, provider, debugToken, token, token;
925
+ return __generator(this, function (_a) {
926
+ switch (_a.label) {
927
+ case 0:
928
+ app = appCheck.app;
929
+ ensureActivated(app);
930
+ provider = getStateReference(app).provider;
931
+ if (!isDebugMode()) return [3 /*break*/, 3];
932
+ return [4 /*yield*/, getDebugToken()];
933
+ case 1:
934
+ debugToken = _a.sent();
935
+ return [4 /*yield*/, exchangeToken(getExchangeDebugTokenRequest(app, debugToken), appCheck.heartbeatServiceProvider)];
936
+ case 2:
937
+ token = (_a.sent()).token;
938
+ return [2 /*return*/, { token: token }];
939
+ case 3: return [4 /*yield*/, provider.getToken()];
940
+ case 4:
941
+ token = (_a.sent()).token;
942
+ return [2 /*return*/, { token: token }];
943
+ }
944
+ });
945
+ });
946
+ }
918
947
  function addTokenListener(appCheck, type, listener, onError) {
919
948
  var app = appCheck.app;
920
949
  var state = getStateReference(app);
@@ -1112,6 +1141,7 @@ function factory(app, heartbeatServiceProvider) {
1112
1141
  function internalFactory(appCheck) {
1113
1142
  return {
1114
1143
  getToken: function (forceRefresh) { return getToken$2(appCheck, forceRefresh); },
1144
+ getLimitedUseToken: function () { return getLimitedUseToken$1(appCheck); },
1115
1145
  addTokenListener: function (listener) {
1116
1146
  return addTokenListener(appCheck, "INTERNAL" /* ListenerType.INTERNAL */, listener);
1117
1147
  },
@@ -1120,7 +1150,7 @@ function internalFactory(appCheck) {
1120
1150
  }
1121
1151
 
1122
1152
  var name = "@firebase/app-check";
1123
- var version = "0.6.5";
1153
+ var version = "0.7.0-canary.4c492e04d";
1124
1154
 
1125
1155
  /**
1126
1156
  * @license
@@ -1717,6 +1747,24 @@ function getToken(appCheckInstance, forceRefresh) {
1717
1747
  });
1718
1748
  });
1719
1749
  }
1750
+ /**
1751
+ * Requests a Firebase App Check token. This method should be used
1752
+ * only if you need to authorize requests to a non-Firebase backend.
1753
+ *
1754
+ * Returns limited-use tokens that are intended for use with your
1755
+ * non-Firebase backend endpoints that are protected with
1756
+ * <a href="https://firebase.google.com/docs/app-check/custom-resource-backend#replay-protection">
1757
+ * Replay Protection</a>. This method
1758
+ * does not affect the token generation behavior of the
1759
+ * #getAppCheckToken() method.
1760
+ *
1761
+ * @param appCheckInstance - The App Check service instance.
1762
+ * @returns The limited use token.
1763
+ * @public
1764
+ */
1765
+ function getLimitedUseToken(appCheckInstance) {
1766
+ return getLimitedUseToken$1(appCheckInstance);
1767
+ }
1720
1768
  /**
1721
1769
  * Wraps `addTokenListener`/`removeTokenListener` methods in an `Observer`
1722
1770
  * pattern for public use.
@@ -1780,5 +1828,5 @@ function registerAppCheck() {
1780
1828
  }
1781
1829
  registerAppCheck();
1782
1830
 
1783
- export { CustomProvider, ReCaptchaEnterpriseProvider, ReCaptchaV3Provider, getToken, initializeAppCheck, onTokenChanged, setTokenAutoRefreshEnabled };
1831
+ export { CustomProvider, ReCaptchaEnterpriseProvider, ReCaptchaV3Provider, getLimitedUseToken, getToken, initializeAppCheck, onTokenChanged, setTokenAutoRefreshEnabled };
1784
1832
  //# sourceMappingURL=index.esm.js.map