frameio 3.2.2 → 4.1.1
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/README.md +159 -4
- package/dist/cjs/BaseClient.d.ts +4 -0
- package/dist/cjs/BaseClient.js +4 -2
- package/dist/cjs/api/resources/accountPermissions/client/Client.js +6 -6
- package/dist/cjs/api/resources/accounts/client/Client.js +13 -13
- package/dist/cjs/api/resources/comments/client/Client.js +48 -48
- package/dist/cjs/api/resources/files/client/Client.js +77 -77
- package/dist/cjs/api/resources/folders/client/Client.js +56 -56
- package/dist/cjs/api/resources/metadata/client/Client.d.ts +4 -4
- package/dist/cjs/api/resources/metadata/client/Client.js +18 -18
- package/dist/cjs/api/resources/metadata/client/requests/BulkUpdateMetadataParams.d.ts +4 -4
- package/dist/cjs/api/resources/metadataFields/client/Client.js +28 -28
- package/dist/cjs/api/resources/projectPermissions/client/Client.js +20 -20
- package/dist/cjs/api/resources/projects/client/Client.js +34 -34
- package/dist/cjs/api/resources/shares/client/Client.d.ts +4 -4
- package/dist/cjs/api/resources/shares/client/Client.js +72 -72
- package/dist/cjs/api/resources/shares/client/requests/AddAssetParams.d.ts +1 -1
- package/dist/cjs/api/resources/shares/client/requests/CreateShareParams.d.ts +2 -2
- package/dist/cjs/api/resources/shares/client/requests/UpdateShareParams.d.ts +1 -1
- package/dist/cjs/api/resources/users/client/Client.js +7 -7
- package/dist/cjs/api/resources/versionStacks/client/Client.d.ts +6 -2
- package/dist/cjs/api/resources/versionStacks/client/Client.js +48 -44
- package/dist/cjs/api/resources/versionStacks/client/requests/VersionStackCreateParams.d.ts +1 -1
- package/dist/cjs/api/resources/webhooks/client/Client.js +34 -34
- package/dist/cjs/api/resources/workspacePermissions/client/Client.js +20 -20
- package/dist/cjs/api/resources/workspaces/client/Client.js +34 -34
- package/dist/cjs/api/types/Account.d.ts +0 -2
- package/dist/cjs/api/types/AuditLogwithIncludes.d.ts +4 -0
- package/dist/cjs/api/types/AuditLogwithIncludes.js +4 -0
- package/dist/cjs/api/types/Filters.d.ts +4 -0
- package/dist/cjs/api/types/Filters.js +4 -0
- package/dist/cjs/index.d.ts +4 -0
- package/dist/cjs/index.js +21 -1
- package/dist/cjs/oauth/BaseAuth.d.ts +66 -0
- package/dist/cjs/oauth/BaseAuth.js +113 -0
- package/dist/cjs/oauth/NativeAppAuth.d.ts +32 -0
- package/dist/cjs/oauth/NativeAppAuth.js +35 -0
- package/dist/cjs/oauth/SPAAuth.d.ts +38 -0
- package/dist/cjs/oauth/SPAAuth.js +96 -0
- package/dist/cjs/oauth/ServerToServerAuth.d.ts +17 -0
- package/dist/cjs/oauth/ServerToServerAuth.js +49 -0
- package/dist/cjs/oauth/TokenManager.d.ts +83 -0
- package/dist/cjs/oauth/TokenManager.js +174 -0
- package/dist/cjs/oauth/WebAppAuth.d.ts +29 -0
- package/dist/cjs/oauth/WebAppAuth.js +88 -0
- package/dist/cjs/oauth/errors.d.ts +41 -0
- package/dist/cjs/oauth/errors.js +83 -0
- package/dist/cjs/oauth/http.d.ts +70 -0
- package/dist/cjs/oauth/http.js +280 -0
- package/dist/cjs/oauth/index.d.ts +34 -0
- package/dist/cjs/oauth/index.js +47 -0
- package/dist/cjs/oauth/logger.d.ts +17 -0
- package/dist/cjs/oauth/logger.js +18 -0
- package/dist/cjs/oauth/pkce.d.ts +30 -0
- package/dist/cjs/oauth/pkce.js +102 -0
- package/dist/cjs/oauth/validation.d.ts +17 -0
- package/dist/cjs/oauth/validation.js +55 -0
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/BaseClient.d.mts +4 -0
- package/dist/esm/BaseClient.mjs +4 -2
- package/dist/esm/api/resources/accountPermissions/client/Client.mjs +7 -7
- package/dist/esm/api/resources/accounts/client/Client.mjs +13 -13
- package/dist/esm/api/resources/comments/client/Client.mjs +49 -49
- package/dist/esm/api/resources/files/client/Client.mjs +78 -78
- package/dist/esm/api/resources/folders/client/Client.mjs +57 -57
- package/dist/esm/api/resources/metadata/client/Client.d.mts +4 -4
- package/dist/esm/api/resources/metadata/client/Client.mjs +19 -19
- package/dist/esm/api/resources/metadata/client/requests/BulkUpdateMetadataParams.d.mts +4 -4
- package/dist/esm/api/resources/metadataFields/client/Client.mjs +29 -29
- package/dist/esm/api/resources/projectPermissions/client/Client.mjs +21 -21
- package/dist/esm/api/resources/projects/client/Client.mjs +35 -35
- package/dist/esm/api/resources/shares/client/Client.d.mts +4 -4
- package/dist/esm/api/resources/shares/client/Client.mjs +73 -73
- package/dist/esm/api/resources/shares/client/requests/AddAssetParams.d.mts +1 -1
- package/dist/esm/api/resources/shares/client/requests/CreateShareParams.d.mts +2 -2
- package/dist/esm/api/resources/shares/client/requests/UpdateShareParams.d.mts +1 -1
- package/dist/esm/api/resources/users/client/Client.mjs +8 -8
- package/dist/esm/api/resources/versionStacks/client/Client.d.mts +6 -2
- package/dist/esm/api/resources/versionStacks/client/Client.mjs +49 -45
- package/dist/esm/api/resources/versionStacks/client/requests/VersionStackCreateParams.d.mts +1 -1
- package/dist/esm/api/resources/webhooks/client/Client.mjs +35 -35
- package/dist/esm/api/resources/workspacePermissions/client/Client.mjs +21 -21
- package/dist/esm/api/resources/workspaces/client/Client.mjs +35 -35
- package/dist/esm/api/types/Account.d.mts +0 -2
- package/dist/esm/api/types/AuditLogwithIncludes.d.mts +4 -0
- package/dist/esm/api/types/AuditLogwithIncludes.mjs +4 -0
- package/dist/esm/api/types/Filters.d.mts +4 -0
- package/dist/esm/api/types/Filters.mjs +4 -0
- package/dist/esm/index.d.mts +4 -0
- package/dist/esm/index.mjs +6 -0
- package/dist/esm/oauth/BaseAuth.d.mts +66 -0
- package/dist/esm/oauth/BaseAuth.mjs +109 -0
- package/dist/esm/oauth/NativeAppAuth.d.mts +32 -0
- package/dist/esm/oauth/NativeAppAuth.mjs +31 -0
- package/dist/esm/oauth/SPAAuth.d.mts +38 -0
- package/dist/esm/oauth/SPAAuth.mjs +92 -0
- package/dist/esm/oauth/ServerToServerAuth.d.mts +17 -0
- package/dist/esm/oauth/ServerToServerAuth.mjs +45 -0
- package/dist/esm/oauth/TokenManager.d.mts +83 -0
- package/dist/esm/oauth/TokenManager.mjs +170 -0
- package/dist/esm/oauth/WebAppAuth.d.mts +29 -0
- package/dist/esm/oauth/WebAppAuth.mjs +84 -0
- package/dist/esm/oauth/errors.d.mts +41 -0
- package/dist/esm/oauth/errors.mjs +72 -0
- package/dist/esm/oauth/http.d.mts +70 -0
- package/dist/esm/oauth/http.mjs +274 -0
- package/dist/esm/oauth/index.d.mts +34 -0
- package/dist/esm/oauth/index.mjs +30 -0
- package/dist/esm/oauth/logger.d.mts +17 -0
- package/dist/esm/oauth/logger.mjs +15 -0
- package/dist/esm/oauth/pkce.d.mts +30 -0
- package/dist/esm/oauth/pkce.mjs +98 -0
- package/dist/esm/oauth/validation.d.mts +17 -0
- package/dist/esm/oauth/validation.mjs +51 -0
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
- package/reference.md +14 -10
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
import { normalizeClientOptionsWithAuth } from "../../../../BaseClient.mjs";
|
|
12
|
-
import { mergeHeaders } from "../../../../core/headers.mjs";
|
|
12
|
+
import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.mjs";
|
|
13
13
|
import * as core from "../../../../core/index.mjs";
|
|
14
14
|
import * as environments from "../../../../environments.mjs";
|
|
15
15
|
import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.mjs";
|
|
@@ -48,22 +48,22 @@ export class WorkspacesClient {
|
|
|
48
48
|
}
|
|
49
49
|
__show(account_id_1, workspace_id_1) {
|
|
50
50
|
return __awaiter(this, arguments, void 0, function* (account_id, workspace_id, request = {}, requestOptions) {
|
|
51
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
51
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
52
52
|
const { include } = request;
|
|
53
53
|
const _queryParams = {
|
|
54
54
|
include: include != null ? include : undefined,
|
|
55
55
|
};
|
|
56
56
|
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
57
|
-
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
58
|
-
const _response = yield ((
|
|
59
|
-
url: core.url.join((
|
|
57
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ "user-agent": (_b = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.userAgent) !== null && _b !== void 0 ? _b : "frameio-ts" }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
58
|
+
const _response = yield ((_c = this._options.fetcher) !== null && _c !== void 0 ? _c : core.fetcher)({
|
|
59
|
+
url: core.url.join((_e = (_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.FrameioEnvironment.Default, `v4/accounts/${core.url.encodePathParam(account_id)}/workspaces/${core.url.encodePathParam(workspace_id)}`),
|
|
60
60
|
method: "GET",
|
|
61
61
|
headers: _headers,
|
|
62
62
|
queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
|
|
63
|
-
timeoutMs: ((
|
|
64
|
-
maxRetries: (
|
|
63
|
+
timeoutMs: ((_h = (_f = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _f !== void 0 ? _f : (_g = this._options) === null || _g === void 0 ? void 0 : _g.timeoutInSeconds) !== null && _h !== void 0 ? _h : 60) * 1000,
|
|
64
|
+
maxRetries: (_j = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _j !== void 0 ? _j : (_k = this._options) === null || _k === void 0 ? void 0 : _k.maxRetries,
|
|
65
65
|
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
66
|
-
fetchFn: (
|
|
66
|
+
fetchFn: (_l = this._options) === null || _l === void 0 ? void 0 : _l.fetch,
|
|
67
67
|
logging: this._options.logging,
|
|
68
68
|
});
|
|
69
69
|
if (_response.ok) {
|
|
@@ -122,18 +122,18 @@ export class WorkspacesClient {
|
|
|
122
122
|
}
|
|
123
123
|
__delete(account_id, workspace_id, requestOptions) {
|
|
124
124
|
return __awaiter(this, void 0, void 0, function* () {
|
|
125
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
125
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
126
126
|
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
127
|
-
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
128
|
-
const _response = yield ((
|
|
129
|
-
url: core.url.join((
|
|
127
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ "user-agent": (_b = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.userAgent) !== null && _b !== void 0 ? _b : "frameio-ts" }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
128
|
+
const _response = yield ((_c = this._options.fetcher) !== null && _c !== void 0 ? _c : core.fetcher)({
|
|
129
|
+
url: core.url.join((_e = (_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.FrameioEnvironment.Default, `v4/accounts/${core.url.encodePathParam(account_id)}/workspaces/${core.url.encodePathParam(workspace_id)}`),
|
|
130
130
|
method: "DELETE",
|
|
131
131
|
headers: _headers,
|
|
132
132
|
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
133
|
-
timeoutMs: ((
|
|
134
|
-
maxRetries: (
|
|
133
|
+
timeoutMs: ((_h = (_f = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _f !== void 0 ? _f : (_g = this._options) === null || _g === void 0 ? void 0 : _g.timeoutInSeconds) !== null && _h !== void 0 ? _h : 60) * 1000,
|
|
134
|
+
maxRetries: (_j = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _j !== void 0 ? _j : (_k = this._options) === null || _k === void 0 ? void 0 : _k.maxRetries,
|
|
135
135
|
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
136
|
-
fetchFn: (
|
|
136
|
+
fetchFn: (_l = this._options) === null || _l === void 0 ? void 0 : _l.fetch,
|
|
137
137
|
logging: this._options.logging,
|
|
138
138
|
});
|
|
139
139
|
if (_response.ok) {
|
|
@@ -194,21 +194,21 @@ export class WorkspacesClient {
|
|
|
194
194
|
}
|
|
195
195
|
__update(account_id, workspace_id, request, requestOptions) {
|
|
196
196
|
return __awaiter(this, void 0, void 0, function* () {
|
|
197
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
197
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
198
198
|
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
199
|
-
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
200
|
-
const _response = yield ((
|
|
201
|
-
url: core.url.join((
|
|
199
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ "user-agent": (_b = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.userAgent) !== null && _b !== void 0 ? _b : "frameio-ts" }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
200
|
+
const _response = yield ((_c = this._options.fetcher) !== null && _c !== void 0 ? _c : core.fetcher)({
|
|
201
|
+
url: core.url.join((_e = (_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.FrameioEnvironment.Default, `v4/accounts/${core.url.encodePathParam(account_id)}/workspaces/${core.url.encodePathParam(workspace_id)}`),
|
|
202
202
|
method: "PATCH",
|
|
203
203
|
headers: _headers,
|
|
204
204
|
contentType: "application/json",
|
|
205
205
|
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
206
206
|
requestType: "json",
|
|
207
207
|
body: request,
|
|
208
|
-
timeoutMs: ((
|
|
209
|
-
maxRetries: (
|
|
208
|
+
timeoutMs: ((_h = (_f = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _f !== void 0 ? _f : (_g = this._options) === null || _g === void 0 ? void 0 : _g.timeoutInSeconds) !== null && _h !== void 0 ? _h : 60) * 1000,
|
|
209
|
+
maxRetries: (_j = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _j !== void 0 ? _j : (_k = this._options) === null || _k === void 0 ? void 0 : _k.maxRetries,
|
|
210
210
|
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
211
|
-
fetchFn: (
|
|
211
|
+
fetchFn: (_l = this._options) === null || _l === void 0 ? void 0 : _l.fetch,
|
|
212
212
|
logging: this._options.logging,
|
|
213
213
|
});
|
|
214
214
|
if (_response.ok) {
|
|
@@ -268,17 +268,17 @@ export class WorkspacesClient {
|
|
|
268
268
|
return __awaiter(this, arguments, void 0, function* (account_id, _request = {}, requestOptions) {
|
|
269
269
|
var _a, _b;
|
|
270
270
|
const list = core.HttpResponsePromise.interceptFunction((_requestUrl) => __awaiter(this, void 0, void 0, function* () {
|
|
271
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
271
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
272
272
|
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
273
|
-
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
274
|
-
const _response = yield ((
|
|
273
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ "user-agent": (_b = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.userAgent) !== null && _b !== void 0 ? _b : "frameio-ts" }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
274
|
+
const _response = yield ((_c = this._options.fetcher) !== null && _c !== void 0 ? _c : core.fetcher)({
|
|
275
275
|
url: _requestUrl,
|
|
276
276
|
method: "GET",
|
|
277
277
|
headers: _headers,
|
|
278
|
-
timeoutMs: ((
|
|
279
|
-
maxRetries: (
|
|
278
|
+
timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
|
|
279
|
+
maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
|
|
280
280
|
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
281
|
-
fetchFn: (
|
|
281
|
+
fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
|
|
282
282
|
logging: this._options.logging,
|
|
283
283
|
});
|
|
284
284
|
if (_response.ok) {
|
|
@@ -353,21 +353,21 @@ export class WorkspacesClient {
|
|
|
353
353
|
}
|
|
354
354
|
__create(account_id, request, requestOptions) {
|
|
355
355
|
return __awaiter(this, void 0, void 0, function* () {
|
|
356
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
356
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
357
357
|
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
358
|
-
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
359
|
-
const _response = yield ((
|
|
360
|
-
url: core.url.join((
|
|
358
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ "user-agent": (_b = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.userAgent) !== null && _b !== void 0 ? _b : "frameio-ts" }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
359
|
+
const _response = yield ((_c = this._options.fetcher) !== null && _c !== void 0 ? _c : core.fetcher)({
|
|
360
|
+
url: core.url.join((_e = (_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.FrameioEnvironment.Default, `v4/accounts/${core.url.encodePathParam(account_id)}/workspaces`),
|
|
361
361
|
method: "POST",
|
|
362
362
|
headers: _headers,
|
|
363
363
|
contentType: "application/json",
|
|
364
364
|
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
365
365
|
requestType: "json",
|
|
366
366
|
body: request,
|
|
367
|
-
timeoutMs: ((
|
|
368
|
-
maxRetries: (
|
|
367
|
+
timeoutMs: ((_h = (_f = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _f !== void 0 ? _f : (_g = this._options) === null || _g === void 0 ? void 0 : _g.timeoutInSeconds) !== null && _h !== void 0 ? _h : 60) * 1000,
|
|
368
|
+
maxRetries: (_j = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _j !== void 0 ? _j : (_k = this._options) === null || _k === void 0 ? void 0 : _k.maxRetries,
|
|
369
369
|
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
370
|
-
fetchFn: (
|
|
370
|
+
fetchFn: (_l = this._options) === null || _l === void 0 ? void 0 : _l.fetch,
|
|
371
371
|
logging: this._options.logging,
|
|
372
372
|
});
|
|
373
373
|
if (_response.ok) {
|
|
@@ -10,8 +10,6 @@ export interface Account {
|
|
|
10
10
|
id: string;
|
|
11
11
|
/** The account image url */
|
|
12
12
|
image?: string | undefined;
|
|
13
|
-
/** Whether mounted storage is enabled for this account */
|
|
14
|
-
mounted_storage_enabled?: boolean | undefined;
|
|
15
13
|
/** Account User Roles */
|
|
16
14
|
roles: Account.Roles.Item[];
|
|
17
15
|
/** The number of bytes of non-archived storage in the account. Value is nil when there is no limit */
|
|
@@ -179,6 +179,9 @@ export declare namespace AuditLogwithIncludes {
|
|
|
179
179
|
readonly ShareCreated: "share_created";
|
|
180
180
|
readonly ShareDeleted: "share_deleted";
|
|
181
181
|
readonly ShareInvitesSent: "share_invites_sent";
|
|
182
|
+
readonly ShareListCreated: "share_list_created";
|
|
183
|
+
readonly ShareListDeleted: "share_list_deleted";
|
|
184
|
+
readonly ShareListUpdated: "share_list_updated";
|
|
182
185
|
readonly ShareReviewersAdded: "share_reviewers_added";
|
|
183
186
|
readonly ShareReviewersRemoved: "share_reviewers_removed";
|
|
184
187
|
readonly ShareUpdated: "share_updated";
|
|
@@ -260,6 +263,7 @@ export declare namespace AuditLogwithIncludes {
|
|
|
260
263
|
readonly Reviewer: "reviewer";
|
|
261
264
|
readonly SbwmTemplate: "sbwm_template";
|
|
262
265
|
readonly Share: "share";
|
|
266
|
+
readonly ShareList: "share_list";
|
|
263
267
|
readonly Subscription: "subscription";
|
|
264
268
|
readonly SubscriptionLineItem: "subscription_line_item";
|
|
265
269
|
readonly Team: "team";
|
|
@@ -165,6 +165,9 @@ export var AuditLogwithIncludes;
|
|
|
165
165
|
ShareCreated: "share_created",
|
|
166
166
|
ShareDeleted: "share_deleted",
|
|
167
167
|
ShareInvitesSent: "share_invites_sent",
|
|
168
|
+
ShareListCreated: "share_list_created",
|
|
169
|
+
ShareListDeleted: "share_list_deleted",
|
|
170
|
+
ShareListUpdated: "share_list_updated",
|
|
168
171
|
ShareReviewersAdded: "share_reviewers_added",
|
|
169
172
|
ShareReviewersRemoved: "share_reviewers_removed",
|
|
170
173
|
ShareUpdated: "share_updated",
|
|
@@ -245,6 +248,7 @@ export var AuditLogwithIncludes;
|
|
|
245
248
|
Reviewer: "reviewer",
|
|
246
249
|
SbwmTemplate: "sbwm_template",
|
|
247
250
|
Share: "share",
|
|
251
|
+
ShareList: "share_list",
|
|
248
252
|
Subscription: "subscription",
|
|
249
253
|
SubscriptionLineItem: "subscription_line_item",
|
|
250
254
|
Team: "team",
|
|
@@ -187,6 +187,9 @@ export declare namespace Filters {
|
|
|
187
187
|
readonly ShareCreated: "share_created";
|
|
188
188
|
readonly ShareDeleted: "share_deleted";
|
|
189
189
|
readonly ShareInvitesSent: "share_invites_sent";
|
|
190
|
+
readonly ShareListCreated: "share_list_created";
|
|
191
|
+
readonly ShareListDeleted: "share_list_deleted";
|
|
192
|
+
readonly ShareListUpdated: "share_list_updated";
|
|
190
193
|
readonly ShareReviewersAdded: "share_reviewers_added";
|
|
191
194
|
readonly ShareReviewersRemoved: "share_reviewers_removed";
|
|
192
195
|
readonly ShareUpdated: "share_updated";
|
|
@@ -269,6 +272,7 @@ export declare namespace Filters {
|
|
|
269
272
|
readonly Reviewer: "reviewer";
|
|
270
273
|
readonly SbwmTemplate: "sbwm_template";
|
|
271
274
|
readonly Share: "share";
|
|
275
|
+
readonly ShareList: "share_list";
|
|
272
276
|
readonly Subscription: "subscription";
|
|
273
277
|
readonly SubscriptionLineItem: "subscription_line_item";
|
|
274
278
|
readonly Team: "team";
|
|
@@ -166,6 +166,9 @@ export var Filters;
|
|
|
166
166
|
ShareCreated: "share_created",
|
|
167
167
|
ShareDeleted: "share_deleted",
|
|
168
168
|
ShareInvitesSent: "share_invites_sent",
|
|
169
|
+
ShareListCreated: "share_list_created",
|
|
170
|
+
ShareListDeleted: "share_list_deleted",
|
|
171
|
+
ShareListUpdated: "share_list_updated",
|
|
169
172
|
ShareReviewersAdded: "share_reviewers_added",
|
|
170
173
|
ShareReviewersRemoved: "share_reviewers_removed",
|
|
171
174
|
ShareUpdated: "share_updated",
|
|
@@ -247,6 +250,7 @@ export var Filters;
|
|
|
247
250
|
Reviewer: "reviewer",
|
|
248
251
|
SbwmTemplate: "sbwm_template",
|
|
249
252
|
Share: "share",
|
|
253
|
+
ShareList: "share_list",
|
|
250
254
|
Subscription: "subscription",
|
|
251
255
|
SubscriptionLineItem: "subscription_line_item",
|
|
252
256
|
Team: "team",
|
package/dist/esm/index.d.mts
CHANGED
|
@@ -4,3 +4,7 @@ export { FrameioClient } from "./Client.mjs";
|
|
|
4
4
|
export { FrameioEnvironment } from "./environments.mjs";
|
|
5
5
|
export { FrameioError, FrameioTimeoutError } from "./errors/index.mjs";
|
|
6
6
|
export * from "./exports.mjs";
|
|
7
|
+
export { ServerToServerAuth, WebAppAuth, SPAAuth, NativeAppAuth } from "./oauth";
|
|
8
|
+
export type { ServerToServerAuthOptions, WebAppAuthOptions, SPAAuthOptions, NativeAppAuthOptions, AuthorizationUrlResult, BaseAuthOptions, Logger, TokenResponse, ExportedTokens, OnTokenRefreshed, } from "./oauth";
|
|
9
|
+
export { FrameioAuthError, AuthenticationError, TokenExpiredError, NetworkError, RateLimitError, PKCEError, ConfigurationError, } from "./oauth";
|
|
10
|
+
export { noopLogger, DEFAULT_IMS_BASE_URL, buildImsUrls } from "./oauth";
|
package/dist/esm/index.mjs
CHANGED
|
@@ -3,3 +3,9 @@ export { FrameioClient } from "./Client.mjs";
|
|
|
3
3
|
export { FrameioEnvironment } from "./environments.mjs";
|
|
4
4
|
export { FrameioError, FrameioTimeoutError } from "./errors/index.mjs";
|
|
5
5
|
export * from "./exports.mjs";
|
|
6
|
+
// Auth flows
|
|
7
|
+
export { ServerToServerAuth, WebAppAuth, SPAAuth, NativeAppAuth } from "./oauth";
|
|
8
|
+
// Auth errors
|
|
9
|
+
export { FrameioAuthError, AuthenticationError, TokenExpiredError, NetworkError, RateLimitError, PKCEError, ConfigurationError, } from "./oauth";
|
|
10
|
+
// Auth utilities
|
|
11
|
+
export { noopLogger, DEFAULT_IMS_BASE_URL, buildImsUrls } from "./oauth";
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base class for all authentication flows.
|
|
3
|
+
*
|
|
4
|
+
* Provides shared token management methods: `getToken`, `revoke`,
|
|
5
|
+
* `exportTokens`, `importTokens`, and the internal `_storeTokens` helper.
|
|
6
|
+
*
|
|
7
|
+
* Also consolidates shared constructor options and initialization logic.
|
|
8
|
+
*/
|
|
9
|
+
import type { Logger } from "./logger";
|
|
10
|
+
import { TokenManager, type ExportedTokens, type OnTokenRefreshed, type TokenResponse } from "./TokenManager";
|
|
11
|
+
/** Default fallback when Adobe IMS doesn't return expires_in. */
|
|
12
|
+
export declare const DEFAULT_EXPIRES_IN = 86400;
|
|
13
|
+
/** Options shared by all auth flow constructors. */
|
|
14
|
+
export interface BaseAuthOptions {
|
|
15
|
+
clientId: string;
|
|
16
|
+
scopes?: string;
|
|
17
|
+
/** IMS base URL for staging/alternative environments. Default: production. */
|
|
18
|
+
imsBaseUrl?: string;
|
|
19
|
+
/** Custom fetch implementation (for proxy, TLS, etc.). */
|
|
20
|
+
fetch?: typeof fetch;
|
|
21
|
+
onTokenRefreshed?: OnTokenRefreshed;
|
|
22
|
+
/** HTTP request timeout in milliseconds. Default: 30000. */
|
|
23
|
+
timeout?: number;
|
|
24
|
+
/** Maximum retries for transient failures. Default: 2. */
|
|
25
|
+
maxRetries?: number;
|
|
26
|
+
/** Seconds before expiry to trigger proactive refresh. Default: 60. */
|
|
27
|
+
refreshBuffer?: number;
|
|
28
|
+
/** Logger instance for diagnostic output. */
|
|
29
|
+
logger?: Logger;
|
|
30
|
+
}
|
|
31
|
+
export declare abstract class BaseAuth {
|
|
32
|
+
protected readonly _clientId: string;
|
|
33
|
+
protected readonly _clientSecret: string | undefined;
|
|
34
|
+
protected readonly _tokenManager: TokenManager;
|
|
35
|
+
protected readonly _timeout: number;
|
|
36
|
+
protected readonly _logger: Logger;
|
|
37
|
+
protected readonly _maxRetries: number;
|
|
38
|
+
protected readonly _revokeUrl: string;
|
|
39
|
+
protected readonly _authorizeUrl: string;
|
|
40
|
+
protected readonly _tokenUrl: string;
|
|
41
|
+
protected readonly _fetch?: typeof fetch;
|
|
42
|
+
constructor(options: BaseAuthOptions, clientSecret?: string);
|
|
43
|
+
/**
|
|
44
|
+
* Subclasses implement this to perform the actual token refresh.
|
|
45
|
+
* For S2S this re-fetches via client_credentials; for WebApp/SPA
|
|
46
|
+
* this uses the stored refresh_token.
|
|
47
|
+
*/
|
|
48
|
+
protected abstract _refresh(): Promise<TokenResponse>;
|
|
49
|
+
/** Return a valid access token, refreshing if necessary. */
|
|
50
|
+
getToken(): Promise<string>;
|
|
51
|
+
/**
|
|
52
|
+
* Revoke the current access and refresh tokens in parallel.
|
|
53
|
+
*
|
|
54
|
+
* Access token revocation may take time to propagate server-side,
|
|
55
|
+
* but refresh token revocation takes effect immediately.
|
|
56
|
+
*/
|
|
57
|
+
revoke(): Promise<void>;
|
|
58
|
+
/** Export current token state for persistence. */
|
|
59
|
+
exportTokens(): ExportedTokens;
|
|
60
|
+
/** Restore token state from a previously exported object. */
|
|
61
|
+
importTokens(data: ExportedTokens): void;
|
|
62
|
+
/** Update the token manager from an Adobe IMS response. */
|
|
63
|
+
protected _storeTokens(result: TokenResponse): void;
|
|
64
|
+
/** Send a token request with the shared options. */
|
|
65
|
+
protected _tokenRequest(data: Record<string, string>): Promise<TokenResponse>;
|
|
66
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base class for all authentication flows.
|
|
3
|
+
*
|
|
4
|
+
* Provides shared token management methods: `getToken`, `revoke`,
|
|
5
|
+
* `exportTokens`, `importTokens`, and the internal `_storeTokens` helper.
|
|
6
|
+
*
|
|
7
|
+
* Also consolidates shared constructor options and initialization logic.
|
|
8
|
+
*/
|
|
9
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
10
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
11
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
12
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
13
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
14
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
15
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
import { buildImsUrls, DEFAULT_IMS_BASE_URL, DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT, revokeRequest, tokenRequest, } from "./http";
|
|
19
|
+
import { ConfigurationError } from "./errors";
|
|
20
|
+
import { noopLogger } from "./logger";
|
|
21
|
+
import { TokenManager } from "./TokenManager";
|
|
22
|
+
/** Default fallback when Adobe IMS doesn't return expires_in. */
|
|
23
|
+
export const DEFAULT_EXPIRES_IN = 86400;
|
|
24
|
+
export class BaseAuth {
|
|
25
|
+
constructor(options, clientSecret) {
|
|
26
|
+
var _a, _b, _c, _d;
|
|
27
|
+
if (!options.clientId) {
|
|
28
|
+
throw new ConfigurationError("clientId is required");
|
|
29
|
+
}
|
|
30
|
+
this._clientId = options.clientId;
|
|
31
|
+
this._clientSecret = clientSecret;
|
|
32
|
+
this._timeout = (_a = options.timeout) !== null && _a !== void 0 ? _a : DEFAULT_TIMEOUT;
|
|
33
|
+
this._maxRetries = (_b = options.maxRetries) !== null && _b !== void 0 ? _b : DEFAULT_MAX_RETRIES;
|
|
34
|
+
this._logger = (_c = options.logger) !== null && _c !== void 0 ? _c : noopLogger;
|
|
35
|
+
this._fetch = options.fetch;
|
|
36
|
+
const urls = buildImsUrls((_d = options.imsBaseUrl) !== null && _d !== void 0 ? _d : DEFAULT_IMS_BASE_URL);
|
|
37
|
+
this._authorizeUrl = urls.authorizeUrl;
|
|
38
|
+
this._tokenUrl = urls.tokenUrl;
|
|
39
|
+
this._revokeUrl = urls.revokeUrl;
|
|
40
|
+
this._tokenManager = new TokenManager({
|
|
41
|
+
refreshFunc: () => this._refresh(),
|
|
42
|
+
refreshBuffer: options.refreshBuffer,
|
|
43
|
+
onTokenRefreshed: options.onTokenRefreshed,
|
|
44
|
+
logger: this._logger,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
// ------------------------------------------------------------------
|
|
48
|
+
// Public API (shared by all flows)
|
|
49
|
+
// ------------------------------------------------------------------
|
|
50
|
+
/** Return a valid access token, refreshing if necessary. */
|
|
51
|
+
getToken() {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
return this._tokenManager.getToken();
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Revoke the current access and refresh tokens in parallel.
|
|
58
|
+
*
|
|
59
|
+
* Access token revocation may take time to propagate server-side,
|
|
60
|
+
* but refresh token revocation takes effect immediately.
|
|
61
|
+
*/
|
|
62
|
+
revoke() {
|
|
63
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
const revokeOpts = {
|
|
65
|
+
timeout: this._timeout,
|
|
66
|
+
logger: this._logger,
|
|
67
|
+
revokeUrl: this._revokeUrl,
|
|
68
|
+
fetch: this._fetch,
|
|
69
|
+
};
|
|
70
|
+
const accessToken = this._tokenManager.accessToken;
|
|
71
|
+
const refreshToken = this._tokenManager.refreshTokenValue;
|
|
72
|
+
const revocations = [];
|
|
73
|
+
if (accessToken) {
|
|
74
|
+
revocations.push(revokeRequest(accessToken, this._clientId, this._clientSecret, revokeOpts));
|
|
75
|
+
}
|
|
76
|
+
if (refreshToken) {
|
|
77
|
+
revocations.push(revokeRequest(refreshToken, this._clientId, this._clientSecret, revokeOpts));
|
|
78
|
+
}
|
|
79
|
+
yield Promise.all(revocations);
|
|
80
|
+
this._tokenManager.clear();
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
/** Export current token state for persistence. */
|
|
84
|
+
exportTokens() {
|
|
85
|
+
return this._tokenManager.exportTokens();
|
|
86
|
+
}
|
|
87
|
+
/** Restore token state from a previously exported object. */
|
|
88
|
+
importTokens(data) {
|
|
89
|
+
this._tokenManager.importTokens(data);
|
|
90
|
+
}
|
|
91
|
+
// ------------------------------------------------------------------
|
|
92
|
+
// Helpers
|
|
93
|
+
// ------------------------------------------------------------------
|
|
94
|
+
/** Update the token manager from an Adobe IMS response. */
|
|
95
|
+
_storeTokens(result) {
|
|
96
|
+
var _a;
|
|
97
|
+
this._tokenManager.setTokens(result.access_token, (_a = result.expires_in) !== null && _a !== void 0 ? _a : DEFAULT_EXPIRES_IN, result.refresh_token);
|
|
98
|
+
}
|
|
99
|
+
/** Send a token request with the shared options. */
|
|
100
|
+
_tokenRequest(data) {
|
|
101
|
+
return tokenRequest(data, {
|
|
102
|
+
timeout: this._timeout,
|
|
103
|
+
maxRetries: this._maxRetries,
|
|
104
|
+
logger: this._logger,
|
|
105
|
+
tokenUrl: this._tokenUrl,
|
|
106
|
+
fetch: this._fetch,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Native App authentication (authorization_code + PKCE).
|
|
3
|
+
*
|
|
4
|
+
* Use for desktop and mobile applications with custom URI schemes
|
|
5
|
+
* or loopback redirects.
|
|
6
|
+
*/
|
|
7
|
+
import { SPAAuth, type SPAAuthOptions } from "./SPAAuth";
|
|
8
|
+
export type NativeAppAuthOptions = SPAAuthOptions;
|
|
9
|
+
/**
|
|
10
|
+
* Authenticate native (desktop / mobile) apps using PKCE.
|
|
11
|
+
*
|
|
12
|
+
* Functionally identical to {@link SPAAuth} but allows custom URI scheme
|
|
13
|
+
* redirect URIs (e.g. `adobe+<hash>://callback`, `myapp://callback`).
|
|
14
|
+
*
|
|
15
|
+
* The parent {@link SPAAuth} validates that `http://` redirect URIs only
|
|
16
|
+
* target loopback addresses, which is also the correct behavior for native
|
|
17
|
+
* apps. Custom URI schemes and `https://` are always allowed.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* const auth = new NativeAppAuth({
|
|
22
|
+
* clientId: '...',
|
|
23
|
+
* redirectUri: 'myapp://callback',
|
|
24
|
+
* });
|
|
25
|
+
* const { url, codeVerifier } = await auth.getAuthorizationUrl({ state: 'random' });
|
|
26
|
+
* // open system browser to url ...
|
|
27
|
+
* await auth.exchangeCode({ code: 'CODE', codeVerifier });
|
|
28
|
+
* const client = new FrameioClient({ token: () => auth.getToken() });
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare class NativeAppAuth extends SPAAuth {
|
|
32
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Native App authentication (authorization_code + PKCE).
|
|
3
|
+
*
|
|
4
|
+
* Use for desktop and mobile applications with custom URI schemes
|
|
5
|
+
* or loopback redirects.
|
|
6
|
+
*/
|
|
7
|
+
import { SPAAuth } from "./SPAAuth";
|
|
8
|
+
/**
|
|
9
|
+
* Authenticate native (desktop / mobile) apps using PKCE.
|
|
10
|
+
*
|
|
11
|
+
* Functionally identical to {@link SPAAuth} but allows custom URI scheme
|
|
12
|
+
* redirect URIs (e.g. `adobe+<hash>://callback`, `myapp://callback`).
|
|
13
|
+
*
|
|
14
|
+
* The parent {@link SPAAuth} validates that `http://` redirect URIs only
|
|
15
|
+
* target loopback addresses, which is also the correct behavior for native
|
|
16
|
+
* apps. Custom URI schemes and `https://` are always allowed.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* const auth = new NativeAppAuth({
|
|
21
|
+
* clientId: '...',
|
|
22
|
+
* redirectUri: 'myapp://callback',
|
|
23
|
+
* });
|
|
24
|
+
* const { url, codeVerifier } = await auth.getAuthorizationUrl({ state: 'random' });
|
|
25
|
+
* // open system browser to url ...
|
|
26
|
+
* await auth.exchangeCode({ code: 'CODE', codeVerifier });
|
|
27
|
+
* const client = new FrameioClient({ token: () => auth.getToken() });
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export class NativeAppAuth extends SPAAuth {
|
|
31
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single Page App authentication (authorization_code + PKCE).
|
|
3
|
+
*
|
|
4
|
+
* Use for browser-based apps that cannot store a client secret.
|
|
5
|
+
*/
|
|
6
|
+
import { BaseAuth, type BaseAuthOptions } from "./BaseAuth";
|
|
7
|
+
import type { TokenResponse } from "./TokenManager";
|
|
8
|
+
/** Returned by `getAuthorizationUrl` — contains the URL and PKCE verifier. */
|
|
9
|
+
export interface AuthorizationUrlResult {
|
|
10
|
+
url: string;
|
|
11
|
+
codeVerifier: string;
|
|
12
|
+
}
|
|
13
|
+
export type SPAAuthOptions = BaseAuthOptions & {
|
|
14
|
+
redirectUri: string;
|
|
15
|
+
};
|
|
16
|
+
export declare class SPAAuth extends BaseAuth {
|
|
17
|
+
protected readonly _redirectUri: string;
|
|
18
|
+
protected readonly _scopes: string;
|
|
19
|
+
constructor(options: SPAAuthOptions);
|
|
20
|
+
/**
|
|
21
|
+
* Build the Adobe IMS authorization URL with PKCE challenge.
|
|
22
|
+
*
|
|
23
|
+
* @returns Object with `url` and `codeVerifier` (store the verifier for exchange).
|
|
24
|
+
*/
|
|
25
|
+
getAuthorizationUrl(options: {
|
|
26
|
+
state: string;
|
|
27
|
+
}): Promise<AuthorizationUrlResult>;
|
|
28
|
+
/**
|
|
29
|
+
* Exchange an authorization code + PKCE verifier for tokens.
|
|
30
|
+
*/
|
|
31
|
+
exchangeCode(options: {
|
|
32
|
+
code: string;
|
|
33
|
+
codeVerifier: string;
|
|
34
|
+
}): Promise<TokenResponse>;
|
|
35
|
+
/** Manually trigger a token refresh. */
|
|
36
|
+
refresh(): Promise<TokenResponse>;
|
|
37
|
+
protected _refresh(): Promise<TokenResponse>;
|
|
38
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single Page App authentication (authorization_code + PKCE).
|
|
3
|
+
*
|
|
4
|
+
* Use for browser-based apps that cannot store a client secret.
|
|
5
|
+
*/
|
|
6
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
7
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
8
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
10
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
11
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
12
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
import { BaseAuth } from "./BaseAuth";
|
|
16
|
+
import { ConfigurationError } from "./errors";
|
|
17
|
+
import { DEFAULT_SCOPES } from "./http";
|
|
18
|
+
import { generateCodeChallenge, generateCodeVerifier } from "./pkce";
|
|
19
|
+
import { validateRedirectUriScheme } from "./validation";
|
|
20
|
+
export class SPAAuth extends BaseAuth {
|
|
21
|
+
constructor(options) {
|
|
22
|
+
var _a;
|
|
23
|
+
if (!options.redirectUri) {
|
|
24
|
+
throw new ConfigurationError("redirectUri is required");
|
|
25
|
+
}
|
|
26
|
+
validateRedirectUriScheme(options.redirectUri);
|
|
27
|
+
super(options);
|
|
28
|
+
this._redirectUri = options.redirectUri;
|
|
29
|
+
this._scopes = (_a = options.scopes) !== null && _a !== void 0 ? _a : DEFAULT_SCOPES;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Build the Adobe IMS authorization URL with PKCE challenge.
|
|
33
|
+
*
|
|
34
|
+
* @returns Object with `url` and `codeVerifier` (store the verifier for exchange).
|
|
35
|
+
*/
|
|
36
|
+
getAuthorizationUrl(options) {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
const codeVerifier = generateCodeVerifier();
|
|
39
|
+
const codeChallenge = yield generateCodeChallenge(codeVerifier);
|
|
40
|
+
const params = new URLSearchParams({
|
|
41
|
+
client_id: this._clientId,
|
|
42
|
+
redirect_uri: this._redirectUri,
|
|
43
|
+
scope: this._scopes,
|
|
44
|
+
response_type: "code",
|
|
45
|
+
state: options.state,
|
|
46
|
+
code_challenge: codeChallenge,
|
|
47
|
+
code_challenge_method: "S256",
|
|
48
|
+
});
|
|
49
|
+
return {
|
|
50
|
+
url: `${this._authorizeUrl}?${params.toString()}`,
|
|
51
|
+
codeVerifier,
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Exchange an authorization code + PKCE verifier for tokens.
|
|
57
|
+
*/
|
|
58
|
+
exchangeCode(options) {
|
|
59
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
const result = yield this._tokenRequest({
|
|
61
|
+
grant_type: "authorization_code",
|
|
62
|
+
client_id: this._clientId,
|
|
63
|
+
code: options.code,
|
|
64
|
+
redirect_uri: this._redirectUri,
|
|
65
|
+
code_verifier: options.codeVerifier,
|
|
66
|
+
});
|
|
67
|
+
this._storeTokens(result);
|
|
68
|
+
return result;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
/** Manually trigger a token refresh. */
|
|
72
|
+
refresh() {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
const result = yield this._refresh();
|
|
75
|
+
this._storeTokens(result);
|
|
76
|
+
return result;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
_refresh() {
|
|
80
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
const refreshTok = this._tokenManager.refreshTokenValue;
|
|
82
|
+
if (!refreshTok) {
|
|
83
|
+
throw new ConfigurationError("No refresh token available. Call exchangeCode() first.");
|
|
84
|
+
}
|
|
85
|
+
return this._tokenRequest({
|
|
86
|
+
grant_type: "refresh_token",
|
|
87
|
+
client_id: this._clientId,
|
|
88
|
+
refresh_token: refreshTok,
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|