aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-util/src/http-client/types.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-util/src/http-client/types.ts')
-rw-r--r--packages/taler-util/src/http-client/types.ts16
1 files changed, 15 insertions, 1 deletions
diff --git a/packages/taler-util/src/http-client/types.ts b/packages/taler-util/src/http-client/types.ts
index 35603264a..94eafb329 100644
--- a/packages/taler-util/src/http-client/types.ts
+++ b/packages/taler-util/src/http-client/types.ts
@@ -185,10 +185,24 @@ export interface LoginToken {
}
declare const __ac_token: unique symbol;
+/**
+ * Use `createAccessToken(string)` function to build one.
+ */
export type AccessToken = string & {
[__ac_token]: true;
};
+/**
+ * Create a rfc8959 access token.
+ * Adds secret-token: prefix if there is none.
+ *
+ * @param token
+ * @returns
+ */
+export function createAccessToken(token: string): AccessToken {
+ return (token.startsWith("secret-token:") ? token : `secret-token:${token}`) as AccessToken
+}
+
declare const __officer_signature: unique symbol;
export type OfficerSignature = string & {
[__officer_signature]: true;
@@ -3604,7 +3618,7 @@ export namespace TalerMerchantApi {
// After the auth token has been set (with method "token"),
// the value must be provided in a "Authorization: Bearer $token"
// header.
- token?: string;
+ token?: AccessToken;
}
export interface InstanceReconfigurationMessage {