@proveanything/smartlinks 2.0.0-alpha.5 → 2.0.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/dist/api/authKit.d.ts +18 -0
- package/dist/api/authKit.js +26 -0
- package/dist/docs/API_SUMMARY.md +4 -1
- package/dist/http.d.ts +7 -7
- package/dist/http.js +1 -1
- package/dist/openapi.yaml +26 -0
- package/docs/API_SUMMARY.md +4 -1
- package/openapi.yaml +26 -0
- package/package.json +1 -1
package/dist/api/authKit.d.ts
CHANGED
|
@@ -54,6 +54,24 @@ export declare namespace authKit {
|
|
|
54
54
|
function googleLogin(clientId: string, idToken: string, trustedDeviceToken?: string): Promise<AuthLoginResponse>;
|
|
55
55
|
/** Google OAuth login via server-side authorization code (public). */
|
|
56
56
|
function googleCodeLogin(clientId: string, code: string, redirectUri: string): Promise<AuthLoginResponse>;
|
|
57
|
+
/**
|
|
58
|
+
* Sign in with LinkedIn (OpenID Connect) via a server-side authorization code (public).
|
|
59
|
+
*
|
|
60
|
+
* LinkedIn has no client-side ID-token SDK, so this is always the authorization-code flow:
|
|
61
|
+
* redirect the browser to LinkedIn's authorize endpoint, then pass the returned one-time
|
|
62
|
+
* `code` (and the exact `redirectUri` used) here — the server exchanges it (with the app's
|
|
63
|
+
* client secret) and verifies the id_token. Mirrors {@link googleCodeLogin}: on success the
|
|
64
|
+
* bearer token is stored and the cache invalidated.
|
|
65
|
+
*
|
|
66
|
+
* Notable error codes (thrown as `SmartlinksApiError`, read via `err.errorCode`):
|
|
67
|
+
* - `MISSING_LINKEDIN_CODE` (400), `LINKEDIN_AUTH_NOT_CONFIGURED` (400),
|
|
68
|
+
* `INVALID_LINKEDIN_TOKEN` (400), `LINKEDIN_AUTH_FAILED` (500)
|
|
69
|
+
* - `ACCOUNT_EXISTS_UNVERIFIED` (409) — same shared verified-to-verified linking policy as
|
|
70
|
+
* {@link googleLogin}/{@link appleLogin}.
|
|
71
|
+
*
|
|
72
|
+
* Gated by step-up MFA — see {@link login} for the `MFA_REQUIRED` error shape.
|
|
73
|
+
*/
|
|
74
|
+
function linkedInLogin(clientId: string, code: string, redirectUri: string, trustedDeviceToken?: string): Promise<AuthLoginResponse>;
|
|
57
75
|
/**
|
|
58
76
|
* Sign in with Apple via an Apple identity token (public).
|
|
59
77
|
*
|
package/dist/api/authKit.js
CHANGED
|
@@ -83,6 +83,32 @@ export var authKit;
|
|
|
83
83
|
return res;
|
|
84
84
|
}
|
|
85
85
|
authKit.googleCodeLogin = googleCodeLogin;
|
|
86
|
+
/**
|
|
87
|
+
* Sign in with LinkedIn (OpenID Connect) via a server-side authorization code (public).
|
|
88
|
+
*
|
|
89
|
+
* LinkedIn has no client-side ID-token SDK, so this is always the authorization-code flow:
|
|
90
|
+
* redirect the browser to LinkedIn's authorize endpoint, then pass the returned one-time
|
|
91
|
+
* `code` (and the exact `redirectUri` used) here — the server exchanges it (with the app's
|
|
92
|
+
* client secret) and verifies the id_token. Mirrors {@link googleCodeLogin}: on success the
|
|
93
|
+
* bearer token is stored and the cache invalidated.
|
|
94
|
+
*
|
|
95
|
+
* Notable error codes (thrown as `SmartlinksApiError`, read via `err.errorCode`):
|
|
96
|
+
* - `MISSING_LINKEDIN_CODE` (400), `LINKEDIN_AUTH_NOT_CONFIGURED` (400),
|
|
97
|
+
* `INVALID_LINKEDIN_TOKEN` (400), `LINKEDIN_AUTH_FAILED` (500)
|
|
98
|
+
* - `ACCOUNT_EXISTS_UNVERIFIED` (409) — same shared verified-to-verified linking policy as
|
|
99
|
+
* {@link googleLogin}/{@link appleLogin}.
|
|
100
|
+
*
|
|
101
|
+
* Gated by step-up MFA — see {@link login} for the `MFA_REQUIRED` error shape.
|
|
102
|
+
*/
|
|
103
|
+
async function linkedInLogin(clientId, code, redirectUri, trustedDeviceToken) {
|
|
104
|
+
const res = await post(`/authkit/${encodeURIComponent(clientId)}/auth/linkedin`, { code, redirectUri, trustedDeviceToken });
|
|
105
|
+
if (res.token) {
|
|
106
|
+
setBearerToken(res.token);
|
|
107
|
+
invalidateCache();
|
|
108
|
+
}
|
|
109
|
+
return res;
|
|
110
|
+
}
|
|
111
|
+
authKit.linkedInLogin = linkedInLogin;
|
|
86
112
|
/**
|
|
87
113
|
* Sign in with Apple via an Apple identity token (public).
|
|
88
114
|
*
|
package/dist/docs/API_SUMMARY.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Smartlinks API Summary
|
|
2
2
|
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.1 | Generated: 2026-09-16T05:23:18.331Z
|
|
4
4
|
|
|
5
5
|
This is a concise summary of all available API functions and types.
|
|
6
6
|
|
|
@@ -9353,6 +9353,9 @@ Google OAuth login via ID token (public). Gated by step-up MFA — see {@link lo
|
|
|
9353
9353
|
**googleCodeLogin**(clientId: string, code: string, redirectUri: string) → `Promise<AuthLoginResponse>`
|
|
9354
9354
|
Google OAuth login via server-side authorization code (public).
|
|
9355
9355
|
|
|
9356
|
+
**linkedInLogin**(clientId: string, code: string, redirectUri: string, trustedDeviceToken?: string) → `Promise<AuthLoginResponse>`
|
|
9357
|
+
Sign in with LinkedIn (OpenID Connect) via a server-side authorization code (public). LinkedIn has no client-side ID-token SDK, so this is always the authorization-code flow: redirect the browser to LinkedIn's authorize endpoint, then pass the returned one-time `code` (and the exact `redirectUri` used) here — the server exchanges it (with the app's client secret) and verifies the id_token. Mirrors {@link googleCodeLogin}: on success the bearer token is stored and the cache invalidated. Notable error codes (thrown as `SmartlinksApiError`, read via `err.errorCode`): - `MISSING_LINKEDIN_CODE` (400), `LINKEDIN_AUTH_NOT_CONFIGURED` (400), `INVALID_LINKEDIN_TOKEN` (400), `LINKEDIN_AUTH_FAILED` (500) - `ACCOUNT_EXISTS_UNVERIFIED` (409) — same shared verified-to-verified linking policy as {@link googleLogin}/{@link appleLogin}. Gated by step-up MFA — see {@link login} for the `MFA_REQUIRED` error shape.
|
|
9358
|
+
|
|
9356
9359
|
**appleLogin**(clientId: string, identityToken: string, opts?: AppleLoginOptions) → `Promise<AuthLoginResponse>`
|
|
9357
9360
|
Sign in with Apple via an Apple identity token (public). Mirrors {@link googleLogin}. On success the returned bearer token is stored automatically and the cache is invalidated. Notable error codes (thrown as `SmartlinksApiError`, read via `err.errorCode`): - `MISSING_APPLE_TOKEN` (400), `APPLE_AUTH_NOT_CONFIGURED` (400), `INVALID_APPLE_TOKEN` (401), `APPLE_AUTH_FAILED` (500) - `ACCOUNT_EXISTS_UNVERIFIED` (409) — an unverified account already owns this email; the server refuses to silently link. `err.details.requiresEmailVerification` is `true`. Recoverable: the user should sign in with their password (or reset it), then link Apple from settings. **The same 409 can now come back from {@link googleLogin}** under the shared verified-to-verified linking policy. Gated by step-up MFA — see {@link login} for the `MFA_REQUIRED` error shape. Pass `opts.trustedDeviceToken` to skip the challenge on a recognized device.
|
|
9358
9361
|
|
package/dist/http.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
type Logger = {
|
|
2
|
+
debug?: (...args: any[]) => void;
|
|
3
|
+
info?: (...args: any[]) => void;
|
|
4
|
+
warn?: (...args: any[]) => void;
|
|
5
|
+
error?: (...args: any[]) => void;
|
|
6
|
+
log?: (...args: any[]) => void;
|
|
7
|
+
} | ((...args: any[]) => void);
|
|
1
8
|
/** Snapshot of cache counters + current keys. Call from the console via `window.__slHttpDiag()`. */
|
|
2
9
|
export declare function getHttpCacheDiagnostics(): {
|
|
3
10
|
size: number;
|
|
@@ -18,13 +25,6 @@ export declare function getHttpCacheDiagnostics(): {
|
|
|
18
25
|
};
|
|
19
26
|
/** Reset the diagnostics counters (does not touch the cache itself). */
|
|
20
27
|
export declare function resetHttpCacheDiagnostics(): void;
|
|
21
|
-
type Logger = {
|
|
22
|
-
debug?: (...args: any[]) => void;
|
|
23
|
-
info?: (...args: any[]) => void;
|
|
24
|
-
warn?: (...args: any[]) => void;
|
|
25
|
-
error?: (...args: any[]) => void;
|
|
26
|
-
log?: (...args: any[]) => void;
|
|
27
|
-
} | ((...args: any[]) => void);
|
|
28
28
|
/** Return whether proxy mode is currently enabled. */
|
|
29
29
|
export declare function isProxyEnabled(): boolean;
|
|
30
30
|
export declare function initializeApi(options: {
|
package/dist/http.js
CHANGED
|
@@ -79,6 +79,7 @@ const TOKEN_STORAGE_KEY = 'sl:token';
|
|
|
79
79
|
let cachePersistenceTtlMs = 7 * 24 * 60 * 60000;
|
|
80
80
|
/** When true (default), serve stale L2 data via SmartlinksOfflineError on network failure. */
|
|
81
81
|
let cacheServeStaleOnOffline = true;
|
|
82
|
+
let logger;
|
|
82
83
|
const httpCacheStats = {
|
|
83
84
|
l1Hits: 0, inflightDedups: 0, l2Hits: 0, networkFetches: 0, skips: 0,
|
|
84
85
|
clears: 0, lastClearReason: null, lastClearAt: 0,
|
|
@@ -278,7 +279,6 @@ function isNetworkError(err) {
|
|
|
278
279
|
// fetch() throws TypeError on network failure; SmartlinksApiError is not a TypeError
|
|
279
280
|
return err instanceof TypeError;
|
|
280
281
|
}
|
|
281
|
-
let logger;
|
|
282
282
|
function logDebug(...args) {
|
|
283
283
|
if (!logger)
|
|
284
284
|
return;
|
package/dist/openapi.yaml
CHANGED
|
@@ -8842,6 +8842,32 @@ paths:
|
|
|
8842
8842
|
description: Unauthorized
|
|
8843
8843
|
404:
|
|
8844
8844
|
description: Not found
|
|
8845
|
+
/authkit/{clientId}/auth/linkedin:
|
|
8846
|
+
post:
|
|
8847
|
+
tags:
|
|
8848
|
+
- authKit
|
|
8849
|
+
summary: authKit.linkedInLogin
|
|
8850
|
+
operationId: authKit_linkedInLogin
|
|
8851
|
+
security: []
|
|
8852
|
+
parameters:
|
|
8853
|
+
- name: clientId
|
|
8854
|
+
in: path
|
|
8855
|
+
required: true
|
|
8856
|
+
schema:
|
|
8857
|
+
type: string
|
|
8858
|
+
responses:
|
|
8859
|
+
200:
|
|
8860
|
+
description: Success
|
|
8861
|
+
content:
|
|
8862
|
+
application/json:
|
|
8863
|
+
schema:
|
|
8864
|
+
$ref: "#/components/schemas/AuthLoginResponse"
|
|
8865
|
+
400:
|
|
8866
|
+
description: Bad request
|
|
8867
|
+
401:
|
|
8868
|
+
description: Unauthorized
|
|
8869
|
+
404:
|
|
8870
|
+
description: Not found
|
|
8845
8871
|
/authkit/{clientId}/auth/login:
|
|
8846
8872
|
post:
|
|
8847
8873
|
tags:
|
package/docs/API_SUMMARY.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Smartlinks API Summary
|
|
2
2
|
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.1 | Generated: 2026-09-16T05:23:18.331Z
|
|
4
4
|
|
|
5
5
|
This is a concise summary of all available API functions and types.
|
|
6
6
|
|
|
@@ -9353,6 +9353,9 @@ Google OAuth login via ID token (public). Gated by step-up MFA — see {@link lo
|
|
|
9353
9353
|
**googleCodeLogin**(clientId: string, code: string, redirectUri: string) → `Promise<AuthLoginResponse>`
|
|
9354
9354
|
Google OAuth login via server-side authorization code (public).
|
|
9355
9355
|
|
|
9356
|
+
**linkedInLogin**(clientId: string, code: string, redirectUri: string, trustedDeviceToken?: string) → `Promise<AuthLoginResponse>`
|
|
9357
|
+
Sign in with LinkedIn (OpenID Connect) via a server-side authorization code (public). LinkedIn has no client-side ID-token SDK, so this is always the authorization-code flow: redirect the browser to LinkedIn's authorize endpoint, then pass the returned one-time `code` (and the exact `redirectUri` used) here — the server exchanges it (with the app's client secret) and verifies the id_token. Mirrors {@link googleCodeLogin}: on success the bearer token is stored and the cache invalidated. Notable error codes (thrown as `SmartlinksApiError`, read via `err.errorCode`): - `MISSING_LINKEDIN_CODE` (400), `LINKEDIN_AUTH_NOT_CONFIGURED` (400), `INVALID_LINKEDIN_TOKEN` (400), `LINKEDIN_AUTH_FAILED` (500) - `ACCOUNT_EXISTS_UNVERIFIED` (409) — same shared verified-to-verified linking policy as {@link googleLogin}/{@link appleLogin}. Gated by step-up MFA — see {@link login} for the `MFA_REQUIRED` error shape.
|
|
9358
|
+
|
|
9356
9359
|
**appleLogin**(clientId: string, identityToken: string, opts?: AppleLoginOptions) → `Promise<AuthLoginResponse>`
|
|
9357
9360
|
Sign in with Apple via an Apple identity token (public). Mirrors {@link googleLogin}. On success the returned bearer token is stored automatically and the cache is invalidated. Notable error codes (thrown as `SmartlinksApiError`, read via `err.errorCode`): - `MISSING_APPLE_TOKEN` (400), `APPLE_AUTH_NOT_CONFIGURED` (400), `INVALID_APPLE_TOKEN` (401), `APPLE_AUTH_FAILED` (500) - `ACCOUNT_EXISTS_UNVERIFIED` (409) — an unverified account already owns this email; the server refuses to silently link. `err.details.requiresEmailVerification` is `true`. Recoverable: the user should sign in with their password (or reset it), then link Apple from settings. **The same 409 can now come back from {@link googleLogin}** under the shared verified-to-verified linking policy. Gated by step-up MFA — see {@link login} for the `MFA_REQUIRED` error shape. Pass `opts.trustedDeviceToken` to skip the challenge on a recognized device.
|
|
9358
9361
|
|
package/openapi.yaml
CHANGED
|
@@ -8842,6 +8842,32 @@ paths:
|
|
|
8842
8842
|
description: Unauthorized
|
|
8843
8843
|
404:
|
|
8844
8844
|
description: Not found
|
|
8845
|
+
/authkit/{clientId}/auth/linkedin:
|
|
8846
|
+
post:
|
|
8847
|
+
tags:
|
|
8848
|
+
- authKit
|
|
8849
|
+
summary: authKit.linkedInLogin
|
|
8850
|
+
operationId: authKit_linkedInLogin
|
|
8851
|
+
security: []
|
|
8852
|
+
parameters:
|
|
8853
|
+
- name: clientId
|
|
8854
|
+
in: path
|
|
8855
|
+
required: true
|
|
8856
|
+
schema:
|
|
8857
|
+
type: string
|
|
8858
|
+
responses:
|
|
8859
|
+
200:
|
|
8860
|
+
description: Success
|
|
8861
|
+
content:
|
|
8862
|
+
application/json:
|
|
8863
|
+
schema:
|
|
8864
|
+
$ref: "#/components/schemas/AuthLoginResponse"
|
|
8865
|
+
400:
|
|
8866
|
+
description: Bad request
|
|
8867
|
+
401:
|
|
8868
|
+
description: Unauthorized
|
|
8869
|
+
404:
|
|
8870
|
+
description: Not found
|
|
8845
8871
|
/authkit/{clientId}/auth/login:
|
|
8846
8872
|
post:
|
|
8847
8873
|
tags:
|