@omerlo/omerlo-webkit 0.0.15 → 0.0.17
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/omerlo/index.d.ts +0 -2
- package/dist/omerlo/reader/endpoints/accounts.d.ts +0 -11
- package/dist/omerlo/reader/endpoints/accounts.js +1 -22
- package/dist/omerlo/reader/endpoints/contents.d.ts +2 -2
- package/dist/omerlo/reader/endpoints/contents.js +5 -5
- package/dist/omerlo/reader/endpoints/distributions.d.ts +2 -2
- package/dist/omerlo/reader/fetchers.d.ts +0 -2
- package/dist/omerlo/reader/index.js +4 -1
- package/dist/omerlo/reader/server/index.d.ts +1 -0
- package/dist/omerlo/reader/server/index.js +1 -0
- package/dist/omerlo/reader/server/oauth.d.ts +1 -0
- package/dist/omerlo/reader/server/oauth.js +23 -0
- package/package.json +1 -1
package/dist/omerlo/index.d.ts
CHANGED
|
@@ -38,6 +38,4 @@ export declare const useReader: (f: typeof fetch) => {
|
|
|
38
38
|
registerDevice: (params: import("./reader").DeviceParams) => Promise<import("./reader/utils/api").ApiResponse<unknown>>;
|
|
39
39
|
userInfo: () => Promise<import("./reader/utils/api").ApiResponse<import("./reader").UserInfo>>;
|
|
40
40
|
userEntitlements: () => Promise<import("./reader/utils/api").ApiResponse<import("./reader").UserEntitlement[]>>;
|
|
41
|
-
verifyAccount: (params: import("./reader").VerifyAccountParams) => void;
|
|
42
|
-
validateAccount: (params: import("./reader").ValidateAccountParams) => void;
|
|
43
41
|
};
|
|
@@ -1,18 +1,7 @@
|
|
|
1
1
|
export declare const accountsFetchers: (f: typeof fetch) => {
|
|
2
2
|
userInfo: () => Promise<import("../utils/api").ApiResponse<UserInfo>>;
|
|
3
3
|
userEntitlements: () => Promise<import("../utils/api").ApiResponse<UserEntitlement[]>>;
|
|
4
|
-
verifyAccount: (params: VerifyAccountParams) => void;
|
|
5
|
-
validateAccount: (params: ValidateAccountParams) => void;
|
|
6
4
|
};
|
|
7
|
-
export interface ValidateAccountParams {
|
|
8
|
-
email: string;
|
|
9
|
-
callbackUrl: string;
|
|
10
|
-
}
|
|
11
|
-
export declare function validateAccount(f: typeof fetch): (params: ValidateAccountParams) => void;
|
|
12
|
-
export interface VerifyAccountParams {
|
|
13
|
-
verification_token: string;
|
|
14
|
-
}
|
|
15
|
-
export declare function verifyAccount(f: typeof fetch): (params: VerifyAccountParams) => void;
|
|
16
5
|
export declare function getUserInfo(f: typeof fetch): () => Promise<import("../utils/api").ApiResponse<UserInfo>>;
|
|
17
6
|
export interface UserInfo {
|
|
18
7
|
name: string;
|
|
@@ -3,31 +3,10 @@ import { request } from '../utils/request';
|
|
|
3
3
|
export const accountsFetchers = (f) => {
|
|
4
4
|
return {
|
|
5
5
|
userInfo: getUserInfo(f),
|
|
6
|
-
userEntitlements: getUserEntitlements(f)
|
|
7
|
-
verifyAccount: verifyAccount(f),
|
|
8
|
-
validateAccount: validateAccount(f)
|
|
6
|
+
userEntitlements: getUserEntitlements(f)
|
|
9
7
|
};
|
|
10
8
|
};
|
|
11
9
|
//
|
|
12
|
-
// Validate an account using the bearer token.
|
|
13
|
-
//
|
|
14
|
-
export function validateAccount(f) {
|
|
15
|
-
return (params) => {
|
|
16
|
-
const queryParams = { email: params.email, callback_url: params.callbackUrl };
|
|
17
|
-
const opts = { queryParams, method: 'post' };
|
|
18
|
-
request(f, '/account/validate', opts);
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
//
|
|
22
|
-
// Verify an account using the signed JWT token generate on account validation.
|
|
23
|
-
//
|
|
24
|
-
export function verifyAccount(f) {
|
|
25
|
-
return (params) => {
|
|
26
|
-
const opts = { queryParams: params };
|
|
27
|
-
request(f, '/account/verify', opts);
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
//
|
|
31
10
|
// Get user's informations associated to the bearer token.
|
|
32
11
|
//
|
|
33
12
|
export function getUserInfo(f) {
|
|
@@ -73,7 +73,7 @@ export type ContentBlockQuote = {
|
|
|
73
73
|
};
|
|
74
74
|
export type ContentBlockRelatedContents = {
|
|
75
75
|
id: string;
|
|
76
|
-
kind: '
|
|
76
|
+
kind: 'related_contents';
|
|
77
77
|
contents: ContentSummary[];
|
|
78
78
|
visual: Visual | null;
|
|
79
79
|
template: ContentBlockTemplate | null;
|
|
@@ -115,7 +115,7 @@ export type ContentBlockVideo = {
|
|
|
115
115
|
template: ContentBlockTemplate | null;
|
|
116
116
|
};
|
|
117
117
|
export type ContentBlock = ContentBlockRichtext | ContentBlockData | ContentBlockHTML | ContentBlockQuote | ContentBlockRelatedContents | ContentBlockQuestion | ContentBlockImage | ContentBlockSlideshow | ContentBlockVideo;
|
|
118
|
-
export type ContentBlockType = 'richtext' | 'data' | 'html' | 'quote' | '
|
|
118
|
+
export type ContentBlockType = 'richtext' | 'data' | 'html' | 'quote' | 'related_contents' | 'question' | 'image' | 'slideshow' | 'video';
|
|
119
119
|
export declare function getContent(f: typeof fetch): (id: string) => Promise<import("../utils/api").ApiResponse<Content>>;
|
|
120
120
|
export declare function listContents(f: typeof fetch): (params?: Partial<PagingParams>) => Promise<import("../utils/api").ApiResponse<ContentSummary[]>>;
|
|
121
121
|
export declare function parseContentSummary(data: ApiData, assocs: ApiAssocs): ContentSummary;
|
|
@@ -22,6 +22,8 @@ export function getContent(f) {
|
|
|
22
22
|
return async (id) => {
|
|
23
23
|
const opts = { parser: parseContent };
|
|
24
24
|
return requestPublisher(f, `media/contents/${id}`, opts);
|
|
25
|
+
// TODO: switch to Reader API (this API is already completed and documented)
|
|
26
|
+
// return request(f, `/contents/${id}`, opts)
|
|
25
27
|
};
|
|
26
28
|
}
|
|
27
29
|
export function listContents(f) {
|
|
@@ -49,7 +51,7 @@ export function parseContentSummary(data, assocs) {
|
|
|
49
51
|
leadText: data.localized.lead_text,
|
|
50
52
|
subtitleHtml: data.localized.subtitle_html,
|
|
51
53
|
subtitleText: data.localized.subtitle_text,
|
|
52
|
-
visual: parseVisual(data.visual, assocs),
|
|
54
|
+
visual: parseVisual(data.localized.visual, assocs),
|
|
53
55
|
meta: buildMeta(data.localized.locale),
|
|
54
56
|
metadata: {},
|
|
55
57
|
authors: getAssocs(assocs, 'profiles', data.localized.author_ids)
|
|
@@ -101,7 +103,7 @@ const ContentBlockParser = {
|
|
|
101
103
|
data: parseContentBlockData,
|
|
102
104
|
html: parseContentBlockHTML,
|
|
103
105
|
quote: parseContentBlockQuote,
|
|
104
|
-
|
|
106
|
+
related_contents: parseContentBlockRelatedContents,
|
|
105
107
|
question: parseContentBlockQuestion,
|
|
106
108
|
image: parseContentBlockImage,
|
|
107
109
|
slideshow: parseContentBlockSlideshow,
|
|
@@ -117,9 +119,7 @@ function getBlockTemplate(data, assocs) {
|
|
|
117
119
|
: null;
|
|
118
120
|
}
|
|
119
121
|
function getBlockContents(data, assocs) {
|
|
120
|
-
return data.
|
|
121
|
-
? getAssocs(assocs, 'contents', data.related_contents)
|
|
122
|
-
: [];
|
|
122
|
+
return data.content_ids ? getAssocs(assocs, 'contents', data.content_ids) : [];
|
|
123
123
|
}
|
|
124
124
|
function parseContentBlockRichtext(data, assocs) {
|
|
125
125
|
return {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { type ApiAssocs, type ApiData, type PagingParams } from '../utils/api';
|
|
2
|
-
import type {
|
|
2
|
+
import type { IssueSummary } from './magazines';
|
|
3
3
|
export declare const distributionFetchers: (f: typeof fetch) => {
|
|
4
4
|
listReleases: (distributionId: string, params?: Partial<PagingParams>) => Promise<import("../utils/api").ApiResponse<Release[]>>;
|
|
5
5
|
};
|
|
6
6
|
export declare function releasesFetcher(f: typeof fetch): (distributionId: string, params?: Partial<PagingParams>) => Promise<import("../utils/api").ApiResponse<Release[]>>;
|
|
7
7
|
export interface Release {
|
|
8
8
|
id: string;
|
|
9
|
-
issue:
|
|
9
|
+
issue: IssueSummary;
|
|
10
10
|
startsAt: Date;
|
|
11
11
|
endsAt: Date | null;
|
|
12
12
|
updatedAt: Date;
|
|
@@ -38,6 +38,4 @@ export declare const fetchers: (f: typeof fetch) => {
|
|
|
38
38
|
registerDevice: (params: import("./endpoints/device").DeviceParams) => Promise<import("./utils/api").ApiResponse<unknown>>;
|
|
39
39
|
userInfo: () => Promise<import("./utils/api").ApiResponse<import("./endpoints/accounts").UserInfo>>;
|
|
40
40
|
userEntitlements: () => Promise<import("./utils/api").ApiResponse<import("./endpoints/accounts").UserEntitlement[]>>;
|
|
41
|
-
verifyAccount: (params: import("./endpoints/accounts").VerifyAccountParams) => void;
|
|
42
|
-
validateAccount: (params: import("./endpoints/accounts").ValidateAccountParams) => void;
|
|
43
41
|
};
|
|
@@ -16,6 +16,9 @@ export function initReader() {
|
|
|
16
16
|
registerAssocParser('contents', parseContentSummary);
|
|
17
17
|
registerAssocParser('issue_types', parseIssueType);
|
|
18
18
|
registerAssocParser('issue_block_configurations', parseIssueBlockConfiguration);
|
|
19
|
-
// NOTE:
|
|
19
|
+
// NOTE: Those ones are for retro compatibility with publisher public api v2
|
|
20
|
+
// Reason is we renamed some assocs keys in Reader API that are different
|
|
21
|
+
// from Publisher public API V2
|
|
20
22
|
registerAssocParser('templates', parseContentTemplate);
|
|
23
|
+
registerAssocParser('block_templates', parseContentBlockTemplate);
|
|
21
24
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function verifyOauth(email: string, oauthUserId: string): Promise<void>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { env } from '$env/dynamic/private';
|
|
2
|
+
import { ApiError } from '../utils/api';
|
|
3
|
+
import { getApplicationToken } from './utils';
|
|
4
|
+
export async function verifyOauth(email, oauthUserId) {
|
|
5
|
+
const url = getOmerloEndpoint();
|
|
6
|
+
const accessToken = await getApplicationToken();
|
|
7
|
+
const headers = new Headers({
|
|
8
|
+
'x-omerlo-media-id': env.PRIVATE_OMERLO_MEDIA_ID,
|
|
9
|
+
Authorization: `Bearer ${accessToken}`
|
|
10
|
+
});
|
|
11
|
+
url.pathname = '/api/media/v1/oauth/verify';
|
|
12
|
+
url.searchParams.append('oauth_user_id', oauthUserId);
|
|
13
|
+
url.searchParams.append('email', email);
|
|
14
|
+
const resp = await fetch(url, { method: 'POST', headers });
|
|
15
|
+
if (resp.ok) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const payload = await resp.json();
|
|
19
|
+
throw new ApiError(resp.status, payload.error, resp.statusText);
|
|
20
|
+
}
|
|
21
|
+
function getOmerloEndpoint() {
|
|
22
|
+
return new URL(`${env.PRIVATE_OMERLO_PROTOCOL}://${env.PRIVATE_OMERLO_HOST}`);
|
|
23
|
+
}
|