@37signals/basecamp 0.13.0 → 0.15.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/README.md +4 -3
- package/dist/client.d.ts +2 -2
- package/dist/client.js +2 -2
- package/dist/download.d.ts +3 -1
- package/dist/download.d.ts.map +1 -1
- package/dist/download.js +17 -4
- package/dist/download.js.map +1 -1
- package/dist/errors.d.ts +27 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +89 -13
- package/dist/errors.js.map +1 -1
- package/dist/generated/metadata.d.ts.map +1 -1
- package/dist/generated/metadata.js +12 -1
- package/dist/generated/metadata.js.map +1 -1
- package/dist/generated/metadata.ts +12 -1
- package/dist/generated/openapi-stripped.json +559 -30
- package/dist/generated/path-mapping.d.ts.map +1 -1
- package/dist/generated/path-mapping.js +1 -0
- package/dist/generated/path-mapping.js.map +1 -1
- package/dist/generated/path-mapping.ts +1 -0
- package/dist/generated/schema.d.ts +468 -29
- package/dist/generated/services/checkins.d.ts +1 -1
- package/dist/generated/services/checkins.d.ts.map +1 -1
- package/dist/generated/services/checkins.ts +1 -1
- package/dist/generated/services/gauges.d.ts +3 -2
- package/dist/generated/services/gauges.d.ts.map +1 -1
- package/dist/generated/services/gauges.ts +2 -2
- package/dist/generated/services/search.d.ts +2 -1
- package/dist/generated/services/search.d.ts.map +1 -1
- package/dist/generated/services/search.ts +1 -1
- package/dist/generated/services/uploads.d.ts +36 -2
- package/dist/generated/services/uploads.d.ts.map +1 -1
- package/dist/generated/services/uploads.js +37 -1
- package/dist/generated/services/uploads.js.map +1 -1
- package/dist/generated/services/uploads.ts +65 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/oauth/authorization-document.d.ts +208 -0
- package/dist/oauth/authorization-document.d.ts.map +1 -0
- package/dist/oauth/authorization-document.js +135 -0
- package/dist/oauth/authorization-document.js.map +1 -0
- package/dist/oauth/identity.d.ts +7 -1
- package/dist/oauth/identity.d.ts.map +1 -1
- package/dist/oauth/identity.js +8 -19
- package/dist/oauth/identity.js.map +1 -1
- package/dist/oauth/index.d.ts +1 -0
- package/dist/oauth/index.d.ts.map +1 -1
- package/dist/oauth/index.js +2 -0
- package/dist/oauth/index.js.map +1 -1
- package/dist/retry.d.ts +23 -0
- package/dist/retry.d.ts.map +1 -1
- package/dist/retry.js +45 -10
- package/dist/retry.js.map +1 -1
- package/dist/services/authorization.d.ts +22 -52
- package/dist/services/authorization.d.ts.map +1 -1
- package/dist/services/authorization.js +14 -32
- package/dist/services/authorization.js.map +1 -1
- package/dist/services/base.d.ts +25 -2
- package/dist/services/base.d.ts.map +1 -1
- package/dist/services/base.js +85 -15
- package/dist/services/base.js.map +1 -1
- package/package.json +6 -4
- package/src/generated/metadata.ts +12 -1
- package/src/generated/openapi-stripped.json +559 -30
- package/src/generated/path-mapping.ts +1 -0
- package/src/generated/schema.d.ts +468 -29
- package/src/generated/services/checkins.ts +1 -1
- package/src/generated/services/gauges.ts +2 -2
- package/src/generated/services/search.ts +1 -1
- package/src/generated/services/uploads.ts +65 -2
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The authorization document, as served by both issuers.
|
|
3
|
+
*
|
|
4
|
+
* Two different services fetch this document — {@link ../services/authorization.js | AuthorizationService}
|
|
5
|
+
* and {@link ./identity.js | discoverIdentity} — and they used to carry a copy of
|
|
6
|
+
* the mapping each. The copies had already drifted apart (`app_href` was required
|
|
7
|
+
* in one and optional in the other), which is exactly how a shape fix gets applied
|
|
8
|
+
* to one caller and missed on the other. The mapping lives here once.
|
|
9
|
+
*
|
|
10
|
+
* This module is a leaf on purpose: it imports nothing from the SDK, so either
|
|
11
|
+
* caller can take a *value* dependency on it without adding a runtime edge to the
|
|
12
|
+
* `base.ts` / `client.ts` cycle.
|
|
13
|
+
*
|
|
14
|
+
* ## Two issuers, two shapes
|
|
15
|
+
*
|
|
16
|
+
* Launchpad and a BC5 (bc3) issuer both serve `GET /authorization.json`, and the
|
|
17
|
+
* documents are not the same shape. bc3 renders its own from
|
|
18
|
+
* `app/views/api/authorizations/show.json.jbuilder`:
|
|
19
|
+
*
|
|
20
|
+
* | Field | Launchpad | BC5 |
|
|
21
|
+
* |---|---|---|
|
|
22
|
+
* | `identity.first_name` / `last_name` / `email_address` | present | absent |
|
|
23
|
+
* | `accounts[].product` / `app_href` | present | absent |
|
|
24
|
+
* | `accounts[].resource` | absent | present (RFC 8707 indicator) |
|
|
25
|
+
* | `scope` | absent | present, BC3-issued tokens only |
|
|
26
|
+
* | `expires_at` | ISO-8601 string | ISO-8601 string (integer epoch **seconds** before bc3 #12646; still accepted) |
|
|
27
|
+
*
|
|
28
|
+
* Every field either issuer omits is typed optional here. The union is modelled
|
|
29
|
+
* rather than either shape alone, because a consumer reaches a BC5 issuer just by
|
|
30
|
+
* passing `endpoint:`, and BC5 issuers serving their own document is the intended
|
|
31
|
+
* end state.
|
|
32
|
+
*
|
|
33
|
+
* @see spec/api-gaps/bc5-authorization-document-shape.md
|
|
34
|
+
*/
|
|
35
|
+
/**
|
|
36
|
+
* Parses `expires_at` from any spelling either issuer has ever used.
|
|
37
|
+
*
|
|
38
|
+
* Both issuers send an ISO-8601 string today; bc3 sent `@token.expires_at.to_i`
|
|
39
|
+
* — integer epoch **seconds** — before bc3 #12646 converged it, and the integer
|
|
40
|
+
* spelling stays accepted (recorded documents, older deploys). The `typeof`
|
|
41
|
+
* branch matters because `new Date(2085213356)` treats the number as
|
|
42
|
+
* *milliseconds* and yields a date in 1970 — a wrong answer rather than an
|
|
43
|
+
* exception, which then reads as an expired credential rather than a schema
|
|
44
|
+
* mismatch.
|
|
45
|
+
*
|
|
46
|
+
* A `0`, a `null` and an absent field are all "no expiry known" and produce an
|
|
47
|
+
* Invalid Date, which is what a `Date`-typed field can say about absence. No
|
|
48
|
+
* production issuer emits any of the three — bc3 tokens validate presence and
|
|
49
|
+
* are always set at mint — so the `0` handling is defensive, guarding the
|
|
50
|
+
* RFC 7591 collision where `0` means "never expires".
|
|
51
|
+
*/
|
|
52
|
+
export function parseExpiresAt(value) {
|
|
53
|
+
if (typeof value === "number") {
|
|
54
|
+
// Epoch seconds, not milliseconds. `0` is the defensive no-expiry sentinel
|
|
55
|
+
// (RFC 7591 gives 0 the meaning "never expires"); no issuer emits it.
|
|
56
|
+
return value === 0 ? new Date(NaN) : new Date(value * 1000);
|
|
57
|
+
}
|
|
58
|
+
if (typeof value === "string" && value !== "") {
|
|
59
|
+
return new Date(value);
|
|
60
|
+
}
|
|
61
|
+
return new Date(NaN);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Filters accounts by product, or reports that it could not.
|
|
65
|
+
*
|
|
66
|
+
* A BC5 document carries no `product` on any account, so filtering it by product
|
|
67
|
+
* matches nothing. Returning `[]` there is silently wrong — the accounts exist,
|
|
68
|
+
* and the caller's next step is to pick a `href` out of a list the SDK just
|
|
69
|
+
* emptied. Instead: when *no* account in the document carries a `product`, the
|
|
70
|
+
* filter is inapplicable, and all accounts are returned with `applied: false` so
|
|
71
|
+
* a caller that cares can tell the two situations apart.
|
|
72
|
+
*
|
|
73
|
+
* When at least one account carries a `product`, the filter is meaningful and is
|
|
74
|
+
* applied normally — an empty result then genuinely means "no account matched".
|
|
75
|
+
*
|
|
76
|
+
* An **empty** account list is the edge that needs saying out loud. "No account
|
|
77
|
+
* carries a `product`" is vacuously true of `[]`, which would report the filter
|
|
78
|
+
* inapplicable — but Launchpad returns `accounts: []` for an identity with no
|
|
79
|
+
* currently accessible accounts, and that document is perfectly filterable. The
|
|
80
|
+
* result is the same list either way, so nothing observable changes; what changes
|
|
81
|
+
* is the claim the flag makes, and `applied: false` would assert "this issuer
|
|
82
|
+
* cannot filter by product" on no evidence at all. An empty list carries no
|
|
83
|
+
* evidence about the issuer, so treat the filter as applied: filtering nothing by
|
|
84
|
+
* anything yields nothing, which is exactly what happened.
|
|
85
|
+
*/
|
|
86
|
+
export function filterAccountsByProduct(accounts, product) {
|
|
87
|
+
const filterable = accounts.length === 0 || accounts.some((a) => a.product !== undefined);
|
|
88
|
+
if (!filterable) {
|
|
89
|
+
return { accounts, applied: false };
|
|
90
|
+
}
|
|
91
|
+
return { accounts: accounts.filter((a) => a.product === product), applied: true };
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Maps a raw authorization document to {@link AuthorizationInfo}.
|
|
95
|
+
*
|
|
96
|
+
* Optionally applies a product filter; see {@link filterAccountsByProduct} for
|
|
97
|
+
* what happens when the document cannot be filtered by product.
|
|
98
|
+
*/
|
|
99
|
+
export function parseAuthorizationDocument(raw, options = {}) {
|
|
100
|
+
let accounts = raw.accounts.map((a) => ({
|
|
101
|
+
id: a.id,
|
|
102
|
+
name: a.name,
|
|
103
|
+
product: a.product,
|
|
104
|
+
href: a.href,
|
|
105
|
+
appHref: a.app_href,
|
|
106
|
+
resource: a.resource,
|
|
107
|
+
hidden: a.hidden,
|
|
108
|
+
expired: a.expired,
|
|
109
|
+
featured: a.featured,
|
|
110
|
+
}));
|
|
111
|
+
let productFilterApplied;
|
|
112
|
+
if (options.filterProduct !== undefined && options.filterProduct !== "") {
|
|
113
|
+
const filtered = filterAccountsByProduct(accounts, options.filterProduct);
|
|
114
|
+
accounts = filtered.accounts;
|
|
115
|
+
productFilterApplied = filtered.applied;
|
|
116
|
+
}
|
|
117
|
+
const info = {
|
|
118
|
+
expiresAt: parseExpiresAt(raw.expires_at),
|
|
119
|
+
identity: {
|
|
120
|
+
id: raw.identity.id,
|
|
121
|
+
firstName: raw.identity.first_name,
|
|
122
|
+
lastName: raw.identity.last_name,
|
|
123
|
+
emailAddress: raw.identity.email_address,
|
|
124
|
+
},
|
|
125
|
+
accounts,
|
|
126
|
+
};
|
|
127
|
+
if (raw.scope !== undefined) {
|
|
128
|
+
info.scope = raw.scope;
|
|
129
|
+
}
|
|
130
|
+
if (productFilterApplied !== undefined) {
|
|
131
|
+
info.productFilterApplied = productFilterApplied;
|
|
132
|
+
}
|
|
133
|
+
return info;
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=authorization-document.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorization-document.js","sourceRoot":"","sources":["../../src/oauth/authorization-document.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AA6HH;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,cAAc,CAAC,KAAyC;IACtE,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,2EAA2E;QAC3E,sEAAsE;QACtE,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;IAC9D,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,EAAE,EAAE,CAAC;QAC9C,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;IACD,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC;AACvB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,uBAAuB,CACrC,QAA6B,EAC7B,OAAe;IAEf,MAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,KAAK,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC;IAC1F,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IACtC,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,OAAO,CAAC,EAAE,OAAO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AK,SAAS,EAAE,CAAC;QAC5B,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC;IACzB,CAAC;IACD,IAAI,oBAAoB,KAAK,SAAS,EAAE,CAAC;QACvC,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;IACnD,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/oauth/identity.d.ts
CHANGED
|
@@ -3,9 +3,15 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Fetches authorization information (identity and accounts) from
|
|
5
5
|
* the Launchpad endpoint without requiring a full client instance.
|
|
6
|
+
*
|
|
7
|
+
* The endpoint is fixed to Launchpad here — unlike
|
|
8
|
+
* {@link ../services/authorization.js | AuthorizationService.getInfo}, which
|
|
9
|
+
* accepts an `endpoint:` override and so can be pointed at a BC5 issuer. Both
|
|
10
|
+
* share one mapping regardless; see `./authorization-document.js` for why the two
|
|
11
|
+
* documents differ and how the shared parser reconciles them.
|
|
6
12
|
*/
|
|
7
13
|
import type { TokenProvider } from "../client.js";
|
|
8
|
-
import type
|
|
14
|
+
import { type AuthorizationInfo } from "./authorization-document.js";
|
|
9
15
|
/**
|
|
10
16
|
* Fetches authorization information using an access token.
|
|
11
17
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/oauth/identity.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/oauth/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAEL,KAAK,iBAAiB,EAEvB,MAAM,6BAA6B,CAAC;AAIrC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,gBAAgB,CAAC,WAAW,EAAE,aAAa,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAoC7F"}
|
package/dist/oauth/identity.js
CHANGED
|
@@ -3,8 +3,15 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Fetches authorization information (identity and accounts) from
|
|
5
5
|
* the Launchpad endpoint without requiring a full client instance.
|
|
6
|
+
*
|
|
7
|
+
* The endpoint is fixed to Launchpad here — unlike
|
|
8
|
+
* {@link ../services/authorization.js | AuthorizationService.getInfo}, which
|
|
9
|
+
* accepts an `endpoint:` override and so can be pointed at a BC5 issuer. Both
|
|
10
|
+
* share one mapping regardless; see `./authorization-document.js` for why the two
|
|
11
|
+
* documents differ and how the shared parser reconciles them.
|
|
6
12
|
*/
|
|
7
13
|
import { BasecampError } from "../errors.js";
|
|
14
|
+
import { parseAuthorizationDocument, } from "./authorization-document.js";
|
|
8
15
|
const AUTHORIZATION_ENDPOINT = "https://launchpad.37signals.com/authorization.json";
|
|
9
16
|
/**
|
|
10
17
|
* Fetches authorization information using an access token.
|
|
@@ -59,24 +66,6 @@ export async function discoverIdentity(accessToken) {
|
|
|
59
66
|
catch {
|
|
60
67
|
throw new BasecampError("api_error", "Identity discovery returned invalid JSON");
|
|
61
68
|
}
|
|
62
|
-
return
|
|
63
|
-
expiresAt: new Date(raw.expires_at),
|
|
64
|
-
identity: {
|
|
65
|
-
id: raw.identity.id,
|
|
66
|
-
firstName: raw.identity.first_name,
|
|
67
|
-
lastName: raw.identity.last_name,
|
|
68
|
-
emailAddress: raw.identity.email_address,
|
|
69
|
-
},
|
|
70
|
-
accounts: raw.accounts.map((a) => ({
|
|
71
|
-
id: a.id,
|
|
72
|
-
name: a.name,
|
|
73
|
-
product: a.product,
|
|
74
|
-
href: a.href,
|
|
75
|
-
appHref: a.app_href ?? "",
|
|
76
|
-
hidden: a.hidden,
|
|
77
|
-
expired: a.expired,
|
|
78
|
-
featured: a.featured,
|
|
79
|
-
})),
|
|
80
|
-
};
|
|
69
|
+
return parseAuthorizationDocument(raw);
|
|
81
70
|
}
|
|
82
71
|
//# sourceMappingURL=identity.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/oauth/identity.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/oauth/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EACL,0BAA0B,GAG3B,MAAM,6BAA6B,CAAC;AAErC,MAAM,sBAAsB,GAAG,oDAAoD,CAAC;AAEpF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,WAA0B;IAC/D,MAAM,KAAK,GAAG,OAAO,WAAW,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,WAAW,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC;IAEpF,IAAI,QAAkB,CAAC;IACvB,IAAI,CAAC;QACH,QAAQ,GAAG,MAAM,KAAK,CAAC,sBAAsB,EAAE;YAC7C,MAAM,EAAE,KAAK;YACb,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,KAAK,EAAE;gBAChC,MAAM,EAAE,kBAAkB;aAC3B;SACF,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,aAAa,CAAC,SAAS,EAAE,8BAA8B,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACvH,CAAC;IAED,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YAC5B,MAAM,IAAI,aAAa,CAAC,eAAe,EAAE,iCAAiC,EAAE;gBAC1E,UAAU,EAAE,GAAG;gBACf,IAAI,EAAE,2CAA2C;aAClD,CAAC,CAAC;QACL,CAAC;QACD,MAAM,IAAI,aAAa,CAAC,WAAW,EAAE,mCAAmC,QAAQ,CAAC,MAAM,EAAE,EAAE;YACzF,UAAU,EAAE,QAAQ,CAAC,MAAM;SAC5B,CAAC,CAAC;IACL,CAAC;IAED,IAAI,GAA6B,CAAC;IAClC,IAAI,CAAC;QACH,GAAG,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAA6B,CAAC;IAC5D,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,aAAa,CAAC,WAAW,EAAE,0CAA0C,CAAC,CAAC;IACnF,CAAC;IAED,OAAO,0BAA0B,CAAC,GAAG,CAAC,CAAC;AACzC,CAAC"}
|
package/dist/oauth/index.d.ts
CHANGED
|
@@ -50,4 +50,5 @@ export { TokenManager, type TokenManagerOptions, } from "./token-manager.js";
|
|
|
50
50
|
export { startCallbackServer, type CallbackResult, type CallbackServerOptions, } from "./callback-server.js";
|
|
51
51
|
export { performInteractiveLogin, type InteractiveLoginOptions, } from "./interactive-login.js";
|
|
52
52
|
export { discoverIdentity, } from "./identity.js";
|
|
53
|
+
export { parseAuthorizationDocument, parseExpiresAt, filterAccountsByProduct, type RawAuthorizationDocument, } from "./authorization-document.js";
|
|
53
54
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/oauth/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAGH,YAAY,EACV,WAAW,EACX,UAAU,EACV,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,yBAAyB,EACzB,cAAc,EACd,6BAA6B,EAC7B,0BAA0B,EAC1B,mBAAmB,GACpB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,0BAA0B,EAC1B,eAAe,EACf,sBAAsB,EACtB,KAAK,gCAAgC,EACrC,KAAK,qBAAqB,EAC1B,KAAK,cAAc,GACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,kBAAkB,EAClB,KAAK,kBAAkB,GACxB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,eAAe,EACf,KAAK,gBAAgB,GACtB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,QAAQ,EACR,yBAAyB,EACzB,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,EACvB,kBAAkB,EAClB,KAAK,eAAe,EACpB,KAAK,2BAA2B,GACjC,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,KAAK,YAAY,GAClB,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,YAAY,EACZ,aAAa,EACb,KAAK,IAAI,GACV,MAAM,WAAW,CAAC;AAGnB,OAAO,EACL,qBAAqB,EACrB,KAAK,eAAe,GACrB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,cAAc,EACd,KAAK,UAAU,GAChB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,YAAY,EACZ,KAAK,mBAAmB,GACzB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,mBAAmB,EACnB,KAAK,cAAc,EACnB,KAAK,qBAAqB,GAC3B,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EACL,uBAAuB,EACvB,KAAK,uBAAuB,GAC7B,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACL,gBAAgB,GACjB,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/oauth/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAGH,YAAY,EACV,WAAW,EACX,UAAU,EACV,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,yBAAyB,EACzB,cAAc,EACd,6BAA6B,EAC7B,0BAA0B,EAC1B,mBAAmB,GACpB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,0BAA0B,EAC1B,eAAe,EACf,sBAAsB,EACtB,KAAK,gCAAgC,EACrC,KAAK,qBAAqB,EAC1B,KAAK,cAAc,GACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,kBAAkB,EAClB,KAAK,kBAAkB,GACxB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,eAAe,EACf,KAAK,gBAAgB,GACtB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,QAAQ,EACR,yBAAyB,EACzB,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,EACvB,kBAAkB,EAClB,KAAK,eAAe,EACpB,KAAK,2BAA2B,GACjC,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,KAAK,YAAY,GAClB,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,YAAY,EACZ,aAAa,EACb,KAAK,IAAI,GACV,MAAM,WAAW,CAAC;AAGnB,OAAO,EACL,qBAAqB,EACrB,KAAK,eAAe,GACrB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,cAAc,EACd,KAAK,UAAU,GAChB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,YAAY,EACZ,KAAK,mBAAmB,GACzB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,mBAAmB,EACnB,KAAK,cAAc,EACnB,KAAK,qBAAqB,GAC3B,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EACL,uBAAuB,EACvB,KAAK,uBAAuB,GAC7B,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACL,gBAAgB,GACjB,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,0BAA0B,EAC1B,cAAc,EACd,uBAAuB,EACvB,KAAK,wBAAwB,GAC9B,MAAM,6BAA6B,CAAC"}
|
package/dist/oauth/index.js
CHANGED
|
@@ -59,4 +59,6 @@ export { startCallbackServer, } from "./callback-server.js";
|
|
|
59
59
|
export { performInteractiveLogin, } from "./interactive-login.js";
|
|
60
60
|
// Identity
|
|
61
61
|
export { discoverIdentity, } from "./identity.js";
|
|
62
|
+
// The authorization document, shared by discoverIdentity and AuthorizationService
|
|
63
|
+
export { parseAuthorizationDocument, parseExpiresAt, filterAccountsByProduct, } from "./authorization-document.js";
|
|
62
64
|
//# sourceMappingURL=index.js.map
|
package/dist/oauth/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/oauth/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAiBH,yBAAyB;AACzB,OAAO,EACL,0BAA0B,EAC1B,eAAe,EACf,sBAAsB,GAIvB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,kBAAkB,GAEnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,eAAe,GAEhB,MAAM,oBAAoB,CAAC;AAE5B,YAAY;AACZ,OAAO,EACL,QAAQ,EACR,yBAAyB,EACzB,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,EACvB,kBAAkB,GAGnB,MAAM,gBAAgB,CAAC;AAExB,iBAAiB;AACjB,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,cAAc,GAEf,MAAM,eAAe,CAAC;AAEvB,iBAAiB;AACjB,OAAO,EACL,YAAY,EACZ,aAAa,GAEd,MAAM,WAAW,CAAC;AAEnB,oBAAoB;AACpB,OAAO,EACL,qBAAqB,GAEtB,MAAM,gBAAgB,CAAC;AAExB,cAAc;AACd,OAAO,EACL,cAAc,GAEf,MAAM,kBAAkB,CAAC;AAE1B,gBAAgB;AAChB,OAAO,EACL,YAAY,GAEb,MAAM,oBAAoB,CAAC;AAE5B,kBAAkB;AAClB,OAAO,EACL,mBAAmB,GAGpB,MAAM,sBAAsB,CAAC;AAE9B,oBAAoB;AACpB,OAAO,EACL,uBAAuB,GAExB,MAAM,wBAAwB,CAAC;AAEhC,WAAW;AACX,OAAO,EACL,gBAAgB,GACjB,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/oauth/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAiBH,yBAAyB;AACzB,OAAO,EACL,0BAA0B,EAC1B,eAAe,EACf,sBAAsB,GAIvB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,kBAAkB,GAEnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,eAAe,GAEhB,MAAM,oBAAoB,CAAC;AAE5B,YAAY;AACZ,OAAO,EACL,QAAQ,EACR,yBAAyB,EACzB,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,EACvB,kBAAkB,GAGnB,MAAM,gBAAgB,CAAC;AAExB,iBAAiB;AACjB,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,cAAc,GAEf,MAAM,eAAe,CAAC;AAEvB,iBAAiB;AACjB,OAAO,EACL,YAAY,EACZ,aAAa,GAEd,MAAM,WAAW,CAAC;AAEnB,oBAAoB;AACpB,OAAO,EACL,qBAAqB,GAEtB,MAAM,gBAAgB,CAAC;AAExB,cAAc;AACd,OAAO,EACL,cAAc,GAEf,MAAM,kBAAkB,CAAC;AAE1B,gBAAgB;AAChB,OAAO,EACL,YAAY,GAEb,MAAM,oBAAoB,CAAC;AAE5B,kBAAkB;AAClB,OAAO,EACL,mBAAmB,GAGpB,MAAM,sBAAsB,CAAC;AAE9B,oBAAoB;AACpB,OAAO,EACL,uBAAuB,GAExB,MAAM,wBAAwB,CAAC;AAEhC,WAAW;AACX,OAAO,EACL,gBAAgB,GACjB,MAAM,eAAe,CAAC;AAEvB,kFAAkF;AAClF,OAAO,EACL,0BAA0B,EAC1B,cAAc,EACd,uBAAuB,GAExB,MAAM,6BAA6B,CAAC"}
|
package/dist/retry.d.ts
CHANGED
|
@@ -25,6 +25,29 @@ export declare const NO_RETRY_CONFIG: RetryConfig;
|
|
|
25
25
|
* `MAX_JITTER_MS`.
|
|
26
26
|
*/
|
|
27
27
|
export declare const MAX_BACKOFF_DELAY_MS = 30000;
|
|
28
|
+
/**
|
|
29
|
+
* Converts server-directed `Retry-After` seconds into a delay a timer will
|
|
30
|
+
* actually serve.
|
|
31
|
+
*
|
|
32
|
+
* `Retry-After` is exempt from the backoff ceiling above (SPEC §7) — it is the
|
|
33
|
+
* server's instruction, not our computation — but it is not exempt from the
|
|
34
|
+
* platform. Above the 32-bit bound `setTimeout` does not sleep longer, it
|
|
35
|
+
* sleeps 1ms, so an unclamped `Retry-After: 2147484` (a hair over 24.85 days)
|
|
36
|
+
* or any HTTP-date more than that far out becomes a tight retry loop against a
|
|
37
|
+
* server that asked for a month — the exact failure the ceiling exists to
|
|
38
|
+
* prevent, arriving through the one value exempt from it.
|
|
39
|
+
*
|
|
40
|
+
* Clamping rather than falling back to backoff follows `oauth/device.ts`:
|
|
41
|
+
* waiting the longest the platform can schedule honours the throttle, where a
|
|
42
|
+
* ~1s backoff would defeat it.
|
|
43
|
+
*
|
|
44
|
+
* This lives HERE, at the scheduling boundary, and not in the parser. The
|
|
45
|
+
* parser's result is also the public `BasecampError.retryAfter`, and clamping
|
|
46
|
+
* there reported a server's 3000000 to callers as 2147483 — the SDK
|
|
47
|
+
* understating what it was told. Parsing and scheduling are different questions
|
|
48
|
+
* and only one of them has a timer.
|
|
49
|
+
*/
|
|
50
|
+
export declare function timerSafeDelayMs(retryAfterSeconds: number): number;
|
|
28
51
|
/**
|
|
29
52
|
* Lifecycle seams the retry loop emits through. The loop begins EVERY attempt
|
|
30
53
|
* and finalizes the attempts it abandons (before the backoff sleep); the
|
package/dist/retry.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;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S,EACf,MAAM,CAAC,EAAE,WAAW,GAAG,IAAI,GAC1B,OAAO,CAAC,QAAQ,CAAC,CAwFnB;AAwCD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,WAAW,CAAC,SAAS,CAAC,EAC/B,OAAO,EAAE,MAAM,GACd,MAAM,CAyBR;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAMlF;AAED;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAgBrE"}
|
package/dist/retry.js
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
* preparation (auth, request construction) via `makeAttempt` and hook
|
|
7
7
|
* emission via `RetryEmit`.
|
|
8
8
|
*/
|
|
9
|
+
// errors.ts imports nothing, so this edge introduces no cycle.
|
|
10
|
+
import { parseRetryAfter } from "./errors.js";
|
|
9
11
|
/** Default retry config used when no operation-specific config is available */
|
|
10
12
|
export const DEFAULT_RETRY_CONFIG = {
|
|
11
13
|
maxAttempts: 3,
|
|
@@ -27,6 +29,38 @@ const MAX_JITTER_MS = 100;
|
|
|
27
29
|
* `MAX_JITTER_MS`.
|
|
28
30
|
*/
|
|
29
31
|
export const MAX_BACKOFF_DELAY_MS = 30_000;
|
|
32
|
+
/**
|
|
33
|
+
* Largest delay `setTimeout` schedules faithfully: Node's timers are backed by
|
|
34
|
+
* a signed 32-bit int, and anything above this is CLAMPED TO 1ms rather than
|
|
35
|
+
* honoured. `client.ts` states the same bound for `AbortSignal.timeout` and
|
|
36
|
+
* `oauth/device.ts` states it in seconds.
|
|
37
|
+
*/
|
|
38
|
+
const MAX_TIMEOUT_MS = 2_147_483_647;
|
|
39
|
+
/**
|
|
40
|
+
* Converts server-directed `Retry-After` seconds into a delay a timer will
|
|
41
|
+
* actually serve.
|
|
42
|
+
*
|
|
43
|
+
* `Retry-After` is exempt from the backoff ceiling above (SPEC §7) — it is the
|
|
44
|
+
* server's instruction, not our computation — but it is not exempt from the
|
|
45
|
+
* platform. Above the 32-bit bound `setTimeout` does not sleep longer, it
|
|
46
|
+
* sleeps 1ms, so an unclamped `Retry-After: 2147484` (a hair over 24.85 days)
|
|
47
|
+
* or any HTTP-date more than that far out becomes a tight retry loop against a
|
|
48
|
+
* server that asked for a month — the exact failure the ceiling exists to
|
|
49
|
+
* prevent, arriving through the one value exempt from it.
|
|
50
|
+
*
|
|
51
|
+
* Clamping rather than falling back to backoff follows `oauth/device.ts`:
|
|
52
|
+
* waiting the longest the platform can schedule honours the throttle, where a
|
|
53
|
+
* ~1s backoff would defeat it.
|
|
54
|
+
*
|
|
55
|
+
* This lives HERE, at the scheduling boundary, and not in the parser. The
|
|
56
|
+
* parser's result is also the public `BasecampError.retryAfter`, and clamping
|
|
57
|
+
* there reported a server's 3000000 to callers as 2147483 — the SDK
|
|
58
|
+
* understating what it was told. Parsing and scheduling are different questions
|
|
59
|
+
* and only one of them has a timer.
|
|
60
|
+
*/
|
|
61
|
+
export function timerSafeDelayMs(retryAfterSeconds) {
|
|
62
|
+
return Math.min(retryAfterSeconds * 1000, MAX_TIMEOUT_MS);
|
|
63
|
+
}
|
|
30
64
|
/**
|
|
31
65
|
* Marks an error thrown during attempt PREPARATION (e.g. a retry's auth
|
|
32
66
|
* refresh) rather than by the transport. The retry loop rethrows it as-is —
|
|
@@ -98,16 +132,17 @@ export async function executeWithRetry(makeAttempt, config, emit, signal) {
|
|
|
98
132
|
if (!config.retryOn.includes(response.status) || attempt >= config.maxAttempts) {
|
|
99
133
|
return response;
|
|
100
134
|
}
|
|
101
|
-
// For 429, respect Retry-After; otherwise back off.
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
135
|
+
// For 429, respect Retry-After; otherwise back off. The header goes through
|
|
136
|
+
// errors.ts's parseRetryAfter — the single SPEC §6 implementation — rather
|
|
137
|
+
// than a local parseInt: 0, a negative value and an unparseable one all
|
|
138
|
+
// come back undefined and fall through to backoff, where the local copy
|
|
139
|
+
// this replaced turned them into a zero or negative sleep.
|
|
140
|
+
const retryAfterSeconds = response.status === 429
|
|
141
|
+
? parseRetryAfter(response.headers.get("Retry-After"))
|
|
142
|
+
: undefined;
|
|
143
|
+
const delay = retryAfterSeconds !== undefined
|
|
144
|
+
? timerSafeDelayMs(retryAfterSeconds)
|
|
145
|
+
: calculateBackoffDelay(config, attempt - 1);
|
|
111
146
|
const statusError = new Error(`HTTP ${response.status}: ${response.statusText || "Request failed"}`);
|
|
112
147
|
// End the failed attempt before sleeping, so a slow backoff cannot leave
|
|
113
148
|
// an attempt open, then announce the upcoming one.
|
package/dist/retry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,+DAA+D;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAY9C,+EAA+E;AAC/E,MAAM,CAAC,MAAM,oBAAoB,GAAgB;IAC/C,WAAW,EAAE,CAAC;IACd,WAAW,EAAE,IAAI;IACjB,OAAO,EAAE,aAAa;IACtB,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC;CACpB,CAAC;AAEF,yDAAyD;AACzD,MAAM,CAAC,MAAM,eAAe,GAAgB;IAC1C,WAAW,EAAE,CAAC;IACd,WAAW,EAAE,CAAC;IACd,OAAO,EAAE,UAAU;IACnB,OAAO,EAAE,EAAE;CACZ,CAAC;AAEF,MAAM,aAAa,GAAG,GA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AE,IAAI,EAAE,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -7,51 +7,8 @@
|
|
|
7
7
|
import { BaseService, type RawClient } from "./base.js";
|
|
8
8
|
import type { BasecampHooks } from "../hooks.js";
|
|
9
9
|
import type { AuthStrategy } from "../auth-strategy.js";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
*/
|
|
13
|
-
export interface Identity {
|
|
14
|
-
/** User's unique identifier */
|
|
15
|
-
id: number;
|
|
16
|
-
/** User's first name */
|
|
17
|
-
firstName: string;
|
|
18
|
-
/** User's last name */
|
|
19
|
-
lastName: string;
|
|
20
|
-
/** User's email address */
|
|
21
|
-
emailAddress: string;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* A Basecamp account the user has access to.
|
|
25
|
-
*/
|
|
26
|
-
export interface AuthorizedAccount {
|
|
27
|
-
/** Account's unique identifier */
|
|
28
|
-
id: number;
|
|
29
|
-
/** Account name */
|
|
30
|
-
name: string;
|
|
31
|
-
/** Product type (e.g., "bc3" for Basecamp, "hey" for HEY) */
|
|
32
|
-
product: string;
|
|
33
|
-
/** API URL for this account */
|
|
34
|
-
href: string;
|
|
35
|
-
/** Web app URL for this account */
|
|
36
|
-
appHref: string;
|
|
37
|
-
/** Whether the account is hidden from the user's view */
|
|
38
|
-
hidden?: boolean;
|
|
39
|
-
/** Whether the account subscription has expired */
|
|
40
|
-
expired?: boolean;
|
|
41
|
-
/** Whether this is the user's featured/primary account */
|
|
42
|
-
featured?: boolean;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Authorization information response.
|
|
46
|
-
*/
|
|
47
|
-
export interface AuthorizationInfo {
|
|
48
|
-
/** Token expiration timestamp */
|
|
49
|
-
expiresAt: Date;
|
|
50
|
-
/** The authenticated user's identity */
|
|
51
|
-
identity: Identity;
|
|
52
|
-
/** List of accounts the user can access */
|
|
53
|
-
accounts: AuthorizedAccount[];
|
|
54
|
-
}
|
|
10
|
+
import { type AuthorizationInfo } from "../oauth/authorization-document.js";
|
|
11
|
+
export type { Identity, AuthorizedAccount, AuthorizationInfo, } from "../oauth/authorization-document.js";
|
|
55
12
|
/**
|
|
56
13
|
* Options for fetching authorization information.
|
|
57
14
|
*/
|
|
@@ -59,19 +16,29 @@ export interface GetAuthorizationInfoOptions {
|
|
|
59
16
|
/**
|
|
60
17
|
* Override the default authorization endpoint URL.
|
|
61
18
|
* Defaults to "https://launchpad.37signals.com/authorization.json"
|
|
19
|
+
*
|
|
20
|
+
* This is also how you point at a BC5 issuer, whose document is a different
|
|
21
|
+
* shape — see `../oauth/authorization-document.js`.
|
|
62
22
|
*/
|
|
63
23
|
endpoint?: string;
|
|
64
24
|
/**
|
|
65
25
|
* Filter accounts by product type.
|
|
66
26
|
* Common values: "bc3" (Basecamp), "bcx" (Basecamp 2), "hey" (HEY)
|
|
27
|
+
*
|
|
28
|
+
* A BC5 document carries no `product` on any account, so the filter cannot
|
|
29
|
+
* apply there. In that case all accounts are returned and
|
|
30
|
+
* `AuthorizationInfo.productFilterApplied` is `false`, rather than the empty
|
|
31
|
+
* list a literal filter would produce.
|
|
67
32
|
*/
|
|
68
33
|
filterProduct?: string;
|
|
69
34
|
}
|
|
70
35
|
/**
|
|
71
36
|
* Service for authorization-related operations.
|
|
72
37
|
*
|
|
73
|
-
* This service communicates with
|
|
74
|
-
* rather than the standard Basecamp
|
|
38
|
+
* This service communicates with an authorization endpoint — Launchpad by
|
|
39
|
+
* default, or a BC5 issuer via `endpoint:` — rather than the standard Basecamp
|
|
40
|
+
* API. The two serve different-shaped documents; see
|
|
41
|
+
* `../oauth/authorization-document.js`.
|
|
75
42
|
*
|
|
76
43
|
* @example
|
|
77
44
|
* ```ts
|
|
@@ -84,9 +51,11 @@ export interface GetAuthorizationInfoOptions {
|
|
|
84
51
|
*
|
|
85
52
|
* // Get all accounts
|
|
86
53
|
* const info = await client.authorization.getInfo();
|
|
87
|
-
* console.log(`Logged in as ${info.identity.
|
|
54
|
+
* console.log(`Logged in as identity ${info.identity.id}`);
|
|
88
55
|
*
|
|
89
|
-
* // Filter to only Basecamp accounts
|
|
56
|
+
* // Filter to only Basecamp accounts. Against a BC5 issuer, whose accounts
|
|
57
|
+
* // carry no `product`, this returns every account with
|
|
58
|
+
* // `productFilterApplied === false` instead of an empty list.
|
|
90
59
|
* const bc3Info = await client.authorization.getInfo({ filterProduct: "bc3" });
|
|
91
60
|
* for (const account of bc3Info.accounts) {
|
|
92
61
|
* console.log(account.name);
|
|
@@ -110,12 +79,13 @@ export declare class AuthorizationService extends BaseService {
|
|
|
110
79
|
* ```ts
|
|
111
80
|
* const info = await authService.getInfo();
|
|
112
81
|
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
82
|
+
* // A BC5 issuer emits only `identity.id`; the name and email fields are
|
|
83
|
+
* // Launchpad's and are `undefined` there.
|
|
84
|
+
* console.log(`User: ${info.identity.id}`);
|
|
115
85
|
* console.log(`Token expires: ${info.expiresAt}`);
|
|
116
86
|
*
|
|
117
87
|
* for (const account of info.accounts) {
|
|
118
|
-
* console.log(`${account.name}
|
|
88
|
+
* console.log(`${account.name}: ${account.href}`);
|
|
119
89
|
* }
|
|
120
90
|
* ```
|
|
121
91
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization.d.ts","sourceRoot":"","sources":["../../src/services/authorization.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"authorization.d.ts","sourceRoot":"","sources":["../../src/services/authorization.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAEL,KAAK,iBAAiB,EAEvB,MAAM,oCAAoC,CAAC;AAI5C,YAAY,EACV,QAAQ,EACR,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,oCAAoC,CAAC;AAE5C;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;;;;OAQG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qBAAa,oBAAqB,SAAQ,WAAW;IACnD,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,SAAS,CAAS;gBAGxB,MAAM,EAAE,SAAS,EACjB,KAAK,EAAE,aAAa,GAAG,SAAS,EAChC,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,MAAM;IAOnB;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACG,OAAO,CAAC,OAAO,GAAE,2BAAgC,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAsCrF"}
|
|
@@ -6,12 +6,15 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { BaseService } from "./base.js";
|
|
8
8
|
import { requireSecureEndpoint } from "../security.js";
|
|
9
|
+
import { parseAuthorizationDocument, } from "../oauth/authorization-document.js";
|
|
9
10
|
const DEFAULT_AUTHORIZATION_ENDPOINT = "https://launchpad.37signals.com/authorization.json";
|
|
10
11
|
/**
|
|
11
12
|
* Service for authorization-related operations.
|
|
12
13
|
*
|
|
13
|
-
* This service communicates with
|
|
14
|
-
* rather than the standard Basecamp
|
|
14
|
+
* This service communicates with an authorization endpoint — Launchpad by
|
|
15
|
+
* default, or a BC5 issuer via `endpoint:` — rather than the standard Basecamp
|
|
16
|
+
* API. The two serve different-shaped documents; see
|
|
17
|
+
* `../oauth/authorization-document.js`.
|
|
15
18
|
*
|
|
16
19
|
* @example
|
|
17
20
|
* ```ts
|
|
@@ -24,9 +27,11 @@ const DEFAULT_AUTHORIZATION_ENDPOINT = "https://launchpad.37signals.com/authoriz
|
|
|
24
27
|
*
|
|
25
28
|
* // Get all accounts
|
|
26
29
|
* const info = await client.authorization.getInfo();
|
|
27
|
-
* console.log(`Logged in as ${info.identity.
|
|
30
|
+
* console.log(`Logged in as identity ${info.identity.id}`);
|
|
28
31
|
*
|
|
29
|
-
* // Filter to only Basecamp accounts
|
|
32
|
+
* // Filter to only Basecamp accounts. Against a BC5 issuer, whose accounts
|
|
33
|
+
* // carry no `product`, this returns every account with
|
|
34
|
+
* // `productFilterApplied === false` instead of an empty list.
|
|
30
35
|
* const bc3Info = await client.authorization.getInfo({ filterProduct: "bc3" });
|
|
31
36
|
* for (const account of bc3Info.accounts) {
|
|
32
37
|
* console.log(account.name);
|
|
@@ -54,12 +59,13 @@ export class AuthorizationService extends BaseService {
|
|
|
54
59
|
* ```ts
|
|
55
60
|
* const info = await authService.getInfo();
|
|
56
61
|
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
62
|
+
* // A BC5 issuer emits only `identity.id`; the name and email fields are
|
|
63
|
+
* // Launchpad's and are `undefined` there.
|
|
64
|
+
* console.log(`User: ${info.identity.id}`);
|
|
59
65
|
* console.log(`Token expires: ${info.expiresAt}`);
|
|
60
66
|
*
|
|
61
67
|
* for (const account of info.accounts) {
|
|
62
|
-
* console.log(`${account.name}
|
|
68
|
+
* console.log(`${account.name}: ${account.href}`);
|
|
63
69
|
* }
|
|
64
70
|
* ```
|
|
65
71
|
*/
|
|
@@ -88,31 +94,7 @@ export class AuthorizationService extends BaseService {
|
|
|
88
94
|
return { data: undefined, error: undefined, response };
|
|
89
95
|
}
|
|
90
96
|
const raw = (await response.json());
|
|
91
|
-
|
|
92
|
-
let accounts = raw.accounts.map((a) => ({
|
|
93
|
-
id: a.id,
|
|
94
|
-
name: a.name,
|
|
95
|
-
product: a.product,
|
|
96
|
-
href: a.href,
|
|
97
|
-
appHref: a.app_href,
|
|
98
|
-
hidden: a.hidden,
|
|
99
|
-
expired: a.expired,
|
|
100
|
-
featured: a.featured,
|
|
101
|
-
}));
|
|
102
|
-
// Filter by product if requested
|
|
103
|
-
if (options.filterProduct) {
|
|
104
|
-
accounts = accounts.filter((a) => a.product === options.filterProduct);
|
|
105
|
-
}
|
|
106
|
-
const data = {
|
|
107
|
-
expiresAt: new Date(raw.expires_at),
|
|
108
|
-
identity: {
|
|
109
|
-
id: raw.identity.id,
|
|
110
|
-
firstName: raw.identity.first_name,
|
|
111
|
-
lastName: raw.identity.last_name,
|
|
112
|
-
emailAddress: raw.identity.email_address,
|
|
113
|
-
},
|
|
114
|
-
accounts,
|
|
115
|
-
};
|
|
97
|
+
const data = parseAuthorizationDocument(raw, { filterProduct: options.filterProduct });
|
|
116
98
|
return { data, error: undefined, response };
|
|
117
99
|
});
|
|
118
100
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization.js","sourceRoot":"","sources":["../../src/services/authorization.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAkB,MAAM,WAAW,CAAC;AAGxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"authorization.js","sourceRoot":"","sources":["../../src/services/authorization.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAkB,MAAM,WAAW,CAAC;AAGxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EACL,0BAA0B,GAG3B,MAAM,oCAAoC,CAAC;AAkC5C,MAAM,8BAA8B,GAAG,oDAAoD,CAAC;AAE5F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,OAAO,oBAAqB,SAAQ,WAAW;IAC3C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