Implement signin flow

This commit is contained in:
Paul Frazee 2022-09-26 21:03:07 -05:00
parent 2e352f383e
commit 0208302907
19 changed files with 652 additions and 300 deletions

View file

@ -10178,9 +10178,13 @@ var Client = class {
};
var ServiceClient = class {
constructor(baseClient, serviceUri) {
this.headers = {};
this.baseClient = baseClient;
this.uri = typeof serviceUri === "string" ? new URL(serviceUri) : serviceUri;
}
setHeader(key, value) {
this.headers[key] = value;
}
async call(methodNsid, params, data, opts) {
const schema = this.baseClient.schemas.get(methodNsid);
if (!schema) {
@ -10188,7 +10192,13 @@ var ServiceClient = class {
}
const httpMethod = getMethodSchemaHTTPMethod(schema);
const httpUri = constructMethodCallUri(schema, this.uri, params);
const httpHeaders = constructMethodCallHeaders(schema, data, opts);
const httpHeaders = constructMethodCallHeaders(schema, data, {
headers: {
...this.headers,
...opts?.headers
},
encoding: opts?.encoding
});
const res = await this.baseClient.fetch(
httpUri,
httpMethod,
@ -10243,13 +10253,28 @@ var methodSchemas = [
encoding: "application/json",
schema: {
type: "object",
required: ["username", "did"],
required: ["username", "did", "password"],
properties: {
username: {
type: "string"
},
did: {
type: "string"
},
password: {
type: "string"
}
}
}
},
output: {
encoding: "application/json",
schema: {
type: "object",
required: ["jwt"],
properties: {
jwt: {
type: "string"
}
}
}
@ -10262,12 +10287,31 @@ var methodSchemas = [
description: "Create an authentication session.",
parameters: {},
input: {
encoding: "",
schema: {}
encoding: "application/json",
schema: {
type: "object",
required: ["username", "password"],
properties: {
username: {
type: "string"
},
password: {
type: "string"
}
}
}
},
output: {
encoding: "",
schema: {}
encoding: "application/json",
schema: {
type: "object",
required: ["jwt"],
properties: {
jwt: {
type: "string"
}
}
}
}
},
{
@ -10326,8 +10370,19 @@ var methodSchemas = [
schema: {}
},
output: {
encoding: "",
schema: {}
encoding: "application/json",
schema: {
type: "object",
required: ["name", "did"],
properties: {
name: {
type: "string"
},
did: {
type: "string"
}
}
}
}
},
{
@ -11518,6 +11573,9 @@ var ServiceClient2 = class {
this.xrpc = xrpcService;
this.todo = new TodoNS(this);
}
setHeader(key, value) {
this.xrpc.setHeader(key, value);
}
};
var TodoNS = class {
constructor(service) {
@ -11686,31 +11744,33 @@ var BadgeRecord = class {
});
return res.data;
}
async create(params, record) {
async create(params, record, headers) {
record.$type = "todo.social.badge";
const res = await this._service.xrpc.call(
"todo.adx.repoCreateRecord",
{ type: "todo.social.badge", ...params },
record,
{ encoding: "application/json" }
{ encoding: "application/json", headers }
);
return res.data;
}
async put(params, record) {
async put(params, record, headers) {
record.$type = "todo.social.badge";
const res = await this._service.xrpc.call(
"todo.adx.repoPutRecord",
{ type: "todo.social.badge", ...params },
record,
{ encoding: "application/json" }
{ encoding: "application/json", headers }
);
return res.data;
}
async delete(params) {
await this._service.xrpc.call("todo.adx.repoDeleteRecord", {
type: "todo.social.badge",
...params
});
async delete(params, headers) {
await this._service.xrpc.call(
"todo.adx.repoDeleteRecord",
{ type: "todo.social.badge", ...params },
void 0,
{ headers }
);
}
};
var FollowRecord = class {
@ -11731,31 +11791,33 @@ var FollowRecord = class {
});
return res.data;
}
async create(params, record) {
async create(params, record, headers) {
record.$type = "todo.social.follow";
const res = await this._service.xrpc.call(
"todo.adx.repoCreateRecord",
{ type: "todo.social.follow", ...params },
record,
{ encoding: "application/json" }
{ encoding: "application/json", headers }
);
return res.data;
}
async put(params, record) {
async put(params, record, headers) {
record.$type = "todo.social.follow";
const res = await this._service.xrpc.call(
"todo.adx.repoPutRecord",
{ type: "todo.social.follow", ...params },
record,
{ encoding: "application/json" }
{ encoding: "application/json", headers }
);
return res.data;
}
async delete(params) {
await this._service.xrpc.call("todo.adx.repoDeleteRecord", {
type: "todo.social.follow",
...params
});
async delete(params, headers) {
await this._service.xrpc.call(
"todo.adx.repoDeleteRecord",
{ type: "todo.social.follow", ...params },
void 0,
{ headers }
);
}
};
var LikeRecord = class {
@ -11776,31 +11838,33 @@ var LikeRecord = class {
});
return res.data;
}
async create(params, record) {
async create(params, record, headers) {
record.$type = "todo.social.like";
const res = await this._service.xrpc.call(
"todo.adx.repoCreateRecord",
{ type: "todo.social.like", ...params },
record,
{ encoding: "application/json" }
{ encoding: "application/json", headers }
);
return res.data;
}
async put(params, record) {
async put(params, record, headers) {
record.$type = "todo.social.like";
const res = await this._service.xrpc.call(
"todo.adx.repoPutRecord",
{ type: "todo.social.like", ...params },
record,
{ encoding: "application/json" }
{ encoding: "application/json", headers }
);
return res.data;
}
async delete(params) {
await this._service.xrpc.call("todo.adx.repoDeleteRecord", {
type: "todo.social.like",
...params
});
async delete(params, headers) {
await this._service.xrpc.call(
"todo.adx.repoDeleteRecord",
{ type: "todo.social.like", ...params },
void 0,
{ headers }
);
}
};
var MediaEmbedRecord = class {
@ -11821,31 +11885,33 @@ var MediaEmbedRecord = class {
});
return res.data;
}
async create(params, record) {
async create(params, record, headers) {
record.$type = "todo.social.mediaEmbed";
const res = await this._service.xrpc.call(
"todo.adx.repoCreateRecord",
{ type: "todo.social.mediaEmbed", ...params },
record,
{ encoding: "application/json" }
{ encoding: "application/json", headers }
);
return res.data;
}
async put(params, record) {
async put(params, record, headers) {
record.$type = "todo.social.mediaEmbed";
const res = await this._service.xrpc.call(
"todo.adx.repoPutRecord",
{ type: "todo.social.mediaEmbed", ...params },
record,
{ encoding: "application/json" }
{ encoding: "application/json", headers }
);
return res.data;
}
async delete(params) {
await this._service.xrpc.call("todo.adx.repoDeleteRecord", {
type: "todo.social.mediaEmbed",
...params
});
async delete(params, headers) {
await this._service.xrpc.call(
"todo.adx.repoDeleteRecord",
{ type: "todo.social.mediaEmbed", ...params },
void 0,
{ headers }
);
}
};
var PostRecord = class {
@ -11866,31 +11932,33 @@ var PostRecord = class {
});
return res.data;
}
async create(params, record) {
async create(params, record, headers) {
record.$type = "todo.social.post";
const res = await this._service.xrpc.call(
"todo.adx.repoCreateRecord",
{ type: "todo.social.post", ...params },
record,
{ encoding: "application/json" }
{ encoding: "application/json", headers }
);
return res.data;
}
async put(params, record) {
async put(params, record, headers) {
record.$type = "todo.social.post";
const res = await this._service.xrpc.call(
"todo.adx.repoPutRecord",
{ type: "todo.social.post", ...params },
record,
{ encoding: "application/json" }
{ encoding: "application/json", headers }
);
return res.data;
}
async delete(params) {
await this._service.xrpc.call("todo.adx.repoDeleteRecord", {
type: "todo.social.post",
...params
});
async delete(params, headers) {
await this._service.xrpc.call(
"todo.adx.repoDeleteRecord",
{ type: "todo.social.post", ...params },
void 0,
{ headers }
);
}
};
var ProfileRecord = class {
@ -11911,31 +11979,33 @@ var ProfileRecord = class {
});
return res.data;
}
async create(params, record) {
async create(params, record, headers) {
record.$type = "todo.social.profile";
const res = await this._service.xrpc.call(
"todo.adx.repoCreateRecord",
{ type: "todo.social.profile", ...params },
record,
{ encoding: "application/json" }
{ encoding: "application/json", headers }
);
return res.data;
}
async put(params, record) {
async put(params, record, headers) {
record.$type = "todo.social.profile";
const res = await this._service.xrpc.call(
"todo.adx.repoPutRecord",
{ type: "todo.social.profile", ...params },
record,
{ encoding: "application/json" }
{ encoding: "application/json", headers }
);
return res.data;
}
async delete(params) {
await this._service.xrpc.call("todo.adx.repoDeleteRecord", {
type: "todo.social.profile",
...params
});
async delete(params, headers) {
await this._service.xrpc.call(
"todo.adx.repoDeleteRecord",
{ type: "todo.social.profile", ...params },
void 0,
{ headers }
);
}
};
var RepostRecord = class {
@ -11956,31 +12026,33 @@ var RepostRecord = class {
});
return res.data;
}
async create(params, record) {
async create(params, record, headers) {
record.$type = "todo.social.repost";
const res = await this._service.xrpc.call(
"todo.adx.repoCreateRecord",
{ type: "todo.social.repost", ...params },
record,
{ encoding: "application/json" }
{ encoding: "application/json", headers }
);
return res.data;
}
async put(params, record) {
async put(params, record, headers) {
record.$type = "todo.social.repost";
const res = await this._service.xrpc.call(
"todo.adx.repoPutRecord",
{ type: "todo.social.repost", ...params },
record,
{ encoding: "application/json" }
{ encoding: "application/json", headers }
);
return res.data;
}
async delete(params) {
await this._service.xrpc.call("todo.adx.repoDeleteRecord", {
type: "todo.social.repost",
...params
});
async delete(params, headers) {
await this._service.xrpc.call(
"todo.adx.repoDeleteRecord",
{ type: "todo.social.repost", ...params },
void 0,
{ headers }
);
}
};
// Annotate the CommonJS export names for ESM import in node:

File diff suppressed because one or more lines are too long

View file

@ -43,6 +43,7 @@ export declare class ServiceClient {
xrpc: XrpcServiceClient;
todo: TodoNS;
constructor(baseClient: Client, xrpcService: XrpcServiceClient);
setHeader(key: string, value: string): void;
}
export declare class TodoNS {
_service: ServiceClient;
@ -103,13 +104,13 @@ export declare class BadgeRecord {
uri: string;
value: TodoSocialBadge.Record;
}>;
create(params: Omit<TodoAdxRepoCreateRecord.QueryParams, 'type'>, record: TodoSocialBadge.Record): Promise<{
create(params: Omit<TodoAdxRepoCreateRecord.QueryParams, 'type'>, record: TodoSocialBadge.Record, headers?: Record<string, string>): Promise<{
uri: string;
}>;
put(params: Omit<TodoAdxRepoPutRecord.QueryParams, 'type'>, record: TodoSocialBadge.Record): Promise<{
put(params: Omit<TodoAdxRepoPutRecord.QueryParams, 'type'>, record: TodoSocialBadge.Record, headers?: Record<string, string>): Promise<{
uri: string;
}>;
delete(params: Omit<TodoAdxRepoDeleteRecord.QueryParams, 'type'>): Promise<void>;
delete(params: Omit<TodoAdxRepoDeleteRecord.QueryParams, 'type'>, headers?: Record<string, string>): Promise<void>;
}
export declare class FollowRecord {
_service: ServiceClient;
@ -124,13 +125,13 @@ export declare class FollowRecord {
uri: string;
value: TodoSocialFollow.Record;
}>;
create(params: Omit<TodoAdxRepoCreateRecord.QueryParams, 'type'>, record: TodoSocialFollow.Record): Promise<{
create(params: Omit<TodoAdxRepoCreateRecord.QueryParams, 'type'>, record: TodoSocialFollow.Record, headers?: Record<string, string>): Promise<{
uri: string;
}>;
put(params: Omit<TodoAdxRepoPutRecord.QueryParams, 'type'>, record: TodoSocialFollow.Record): Promise<{
put(params: Omit<TodoAdxRepoPutRecord.QueryParams, 'type'>, record: TodoSocialFollow.Record, headers?: Record<string, string>): Promise<{
uri: string;
}>;
delete(params: Omit<TodoAdxRepoDeleteRecord.QueryParams, 'type'>): Promise<void>;
delete(params: Omit<TodoAdxRepoDeleteRecord.QueryParams, 'type'>, headers?: Record<string, string>): Promise<void>;
}
export declare class LikeRecord {
_service: ServiceClient;
@ -145,13 +146,13 @@ export declare class LikeRecord {
uri: string;
value: TodoSocialLike.Record;
}>;
create(params: Omit<TodoAdxRepoCreateRecord.QueryParams, 'type'>, record: TodoSocialLike.Record): Promise<{
create(params: Omit<TodoAdxRepoCreateRecord.QueryParams, 'type'>, record: TodoSocialLike.Record, headers?: Record<string, string>): Promise<{
uri: string;
}>;
put(params: Omit<TodoAdxRepoPutRecord.QueryParams, 'type'>, record: TodoSocialLike.Record): Promise<{
put(params: Omit<TodoAdxRepoPutRecord.QueryParams, 'type'>, record: TodoSocialLike.Record, headers?: Record<string, string>): Promise<{
uri: string;
}>;
delete(params: Omit<TodoAdxRepoDeleteRecord.QueryParams, 'type'>): Promise<void>;
delete(params: Omit<TodoAdxRepoDeleteRecord.QueryParams, 'type'>, headers?: Record<string, string>): Promise<void>;
}
export declare class MediaEmbedRecord {
_service: ServiceClient;
@ -166,13 +167,13 @@ export declare class MediaEmbedRecord {
uri: string;
value: TodoSocialMediaEmbed.Record;
}>;
create(params: Omit<TodoAdxRepoCreateRecord.QueryParams, 'type'>, record: TodoSocialMediaEmbed.Record): Promise<{
create(params: Omit<TodoAdxRepoCreateRecord.QueryParams, 'type'>, record: TodoSocialMediaEmbed.Record, headers?: Record<string, string>): Promise<{
uri: string;
}>;
put(params: Omit<TodoAdxRepoPutRecord.QueryParams, 'type'>, record: TodoSocialMediaEmbed.Record): Promise<{
put(params: Omit<TodoAdxRepoPutRecord.QueryParams, 'type'>, record: TodoSocialMediaEmbed.Record, headers?: Record<string, string>): Promise<{
uri: string;
}>;
delete(params: Omit<TodoAdxRepoDeleteRecord.QueryParams, 'type'>): Promise<void>;
delete(params: Omit<TodoAdxRepoDeleteRecord.QueryParams, 'type'>, headers?: Record<string, string>): Promise<void>;
}
export declare class PostRecord {
_service: ServiceClient;
@ -187,13 +188,13 @@ export declare class PostRecord {
uri: string;
value: TodoSocialPost.Record;
}>;
create(params: Omit<TodoAdxRepoCreateRecord.QueryParams, 'type'>, record: TodoSocialPost.Record): Promise<{
create(params: Omit<TodoAdxRepoCreateRecord.QueryParams, 'type'>, record: TodoSocialPost.Record, headers?: Record<string, string>): Promise<{
uri: string;
}>;
put(params: Omit<TodoAdxRepoPutRecord.QueryParams, 'type'>, record: TodoSocialPost.Record): Promise<{
put(params: Omit<TodoAdxRepoPutRecord.QueryParams, 'type'>, record: TodoSocialPost.Record, headers?: Record<string, string>): Promise<{
uri: string;
}>;
delete(params: Omit<TodoAdxRepoDeleteRecord.QueryParams, 'type'>): Promise<void>;
delete(params: Omit<TodoAdxRepoDeleteRecord.QueryParams, 'type'>, headers?: Record<string, string>): Promise<void>;
}
export declare class ProfileRecord {
_service: ServiceClient;
@ -208,13 +209,13 @@ export declare class ProfileRecord {
uri: string;
value: TodoSocialProfile.Record;
}>;
create(params: Omit<TodoAdxRepoCreateRecord.QueryParams, 'type'>, record: TodoSocialProfile.Record): Promise<{
create(params: Omit<TodoAdxRepoCreateRecord.QueryParams, 'type'>, record: TodoSocialProfile.Record, headers?: Record<string, string>): Promise<{
uri: string;
}>;
put(params: Omit<TodoAdxRepoPutRecord.QueryParams, 'type'>, record: TodoSocialProfile.Record): Promise<{
put(params: Omit<TodoAdxRepoPutRecord.QueryParams, 'type'>, record: TodoSocialProfile.Record, headers?: Record<string, string>): Promise<{
uri: string;
}>;
delete(params: Omit<TodoAdxRepoDeleteRecord.QueryParams, 'type'>): Promise<void>;
delete(params: Omit<TodoAdxRepoDeleteRecord.QueryParams, 'type'>, headers?: Record<string, string>): Promise<void>;
}
export declare class RepostRecord {
_service: ServiceClient;
@ -229,11 +230,11 @@ export declare class RepostRecord {
uri: string;
value: TodoSocialRepost.Record;
}>;
create(params: Omit<TodoAdxRepoCreateRecord.QueryParams, 'type'>, record: TodoSocialRepost.Record): Promise<{
create(params: Omit<TodoAdxRepoCreateRecord.QueryParams, 'type'>, record: TodoSocialRepost.Record, headers?: Record<string, string>): Promise<{
uri: string;
}>;
put(params: Omit<TodoAdxRepoPutRecord.QueryParams, 'type'>, record: TodoSocialRepost.Record): Promise<{
put(params: Omit<TodoAdxRepoPutRecord.QueryParams, 'type'>, record: TodoSocialRepost.Record, headers?: Record<string, string>): Promise<{
uri: string;
}>;
delete(params: Omit<TodoAdxRepoDeleteRecord.QueryParams, 'type'>): Promise<void>;
delete(params: Omit<TodoAdxRepoDeleteRecord.QueryParams, 'type'>, headers?: Record<string, string>): Promise<void>;
}

View file

@ -8,9 +8,14 @@ export interface CallOptions {
export interface InputSchema {
username: string;
did: string;
password: string;
}
export interface OutputSchema {
jwt: string;
}
export interface Response {
success: boolean;
error: boolean;
headers: Headers;
data: OutputSchema;
}

View file

@ -3,13 +3,14 @@ export interface QueryParams {
}
export interface CallOptions {
headers?: Headers;
encoding: '';
encoding: 'application/json';
}
export interface InputSchema {
[k: string]: unknown;
username: string;
password: string;
}
export interface OutputSchema {
[k: string]: unknown;
jwt: string;
}
export interface Response {
success: boolean;

View file

@ -9,7 +9,8 @@ export interface InputSchema {
[k: string]: unknown;
}
export interface OutputSchema {
[k: string]: unknown;
name: string;
did: string;
}
export interface Response {
success: boolean;

File diff suppressed because one or more lines are too long