Skip to content
This repository has been archived by the owner on Jul 25, 2024. It is now read-only.

Commit

Permalink
fix: testing
Browse files Browse the repository at this point in the history
  • Loading branch information
einaralex committed Nov 8, 2023
1 parent a5dd104 commit 24389c9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
28 changes: 13 additions & 15 deletions libs/sdk/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ import {

// import pjson from "../package.json";

// test

const isServer = typeof window === 'undefined';

export class MoneriumClient {
Expand Down Expand Up @@ -134,7 +132,7 @@ export class MoneriumClient {

// TODO: TEST auto link & manual link + address
async connect(
client?: AuthorizationCodeCredentials | ClientCredentials,
client?: AuthorizationCodeCredentials | ClientCredentials
): Promise<boolean> {
const clientId = client?.clientId || this.#client?.clientId;
const clientSecret =
Expand All @@ -146,7 +144,7 @@ export class MoneriumClient {
throw new Error('Only use client credentials on server side');
}
await this.#clientCredentialsAuthorization(
this.#client as ClientCredentials,
this.#client as ClientCredentials
);
return !!this.bearerProfile;
}
Expand Down Expand Up @@ -214,15 +212,15 @@ export class MoneriumClient {
'post',
`auth/token`,
params as unknown as Record<string, string>,
true,
true
)
.then((res) => {
this.bearerProfile = res;
this.isAuthorized = !!res;
this.#authorizationHeader = `Bearer ${res?.access_token}`;
window.sessionStorage.setItem(
STORAGE_REFRESH_TOKEN,
this.bearerProfile?.refresh_token || '',
this.bearerProfile?.refresh_token || ''
);
})
.catch((err) => {
Expand Down Expand Up @@ -308,7 +306,7 @@ export class MoneriumClient {
return this.#api(
'post',
`profiles/${profileId}/addresses`,
JSON.stringify(body),
JSON.stringify(body)
);
}

Expand All @@ -322,7 +320,7 @@ export class MoneriumClient {
return this.#api<Order>(
'post',
`profiles/${profileId}/orders`,
JSON.stringify(req),
JSON.stringify(req)
);
} else {
return this.#api<Order>('post', `orders`, JSON.stringify(req));
Expand All @@ -334,14 +332,14 @@ export class MoneriumClient {
*/
uploadSupportingDocument(document: File): Promise<SupportingDoc> {
const searchParams = urlEncoded(
document as unknown as Record<string, string>,
document as unknown as Record<string, string>
);

return this.#api<SupportingDoc>(
'post',
'files/supporting-document',
searchParams,
true,
true
);
}

Expand All @@ -351,7 +349,7 @@ export class MoneriumClient {
method: string,
resource: string,
body?: BodyInit | Record<string, string>,
isFormEncoded?: boolean,
isFormEncoded?: boolean
): Promise<T> {
return rest<T>(
`${this.#env.api}/${resource}`,
Expand All @@ -362,7 +360,7 @@ export class MoneriumClient {
'Content-Type': `application/${
isFormEncoded ? 'x-www-form-urlencoded' : 'json'
}`,
},
}
);
}

Expand All @@ -375,7 +373,7 @@ export class MoneriumClient {
#authCodeAuthorization = async (
clientId: string,
redirectUrl: string,
authCode: string,
authCode: string
) => {
const codeVerifier = sessionStorage.getItem(STORAGE_CODE_VERIFIER) || '';

Expand Down Expand Up @@ -408,7 +406,7 @@ export class MoneriumClient {

#refreshTokenAuthorization = async (
clientId: string,
refreshToken: string,
refreshToken: string
) => {
return await this.getBearerToken({
refresh_token: refreshToken,
Expand Down Expand Up @@ -445,7 +443,7 @@ export class MoneriumClient {
const notification = JSON.parse(event.data) as OrderNotification;

this.#subscriptions.get(notification.meta.state as OrderState)?.(
notification,
notification
);
});

Expand Down
7 changes: 7 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
"pull-request-header": "Monerium SDK React Provider release :rocket:",
"changelog-types": "[{\"type\":\"feat\",\"section\":\"Features\",\"hidden\":false},{\"type\":\"fix\",\"section\":\"Bug Fixes\",\"hidden\":false},{\"type\":\"chore\",\"section\":\"Miscellaneous\",\"hidden\":false},{ \"type\": \"revert\", \"section\": \"Reverts\", \"hidden\": false }]",
"target-branch": "main"
},
"libs/sdk": {
"release-type": "node",
"package-name": "sdk",
"pull-request-header": "Monerium SDK release :rocket:",
"changelog-types": "[{\"type\":\"feat\",\"section\":\"Features\",\"hidden\":false},{\"type\":\"fix\",\"section\":\"Bug Fixes\",\"hidden\":false},{\"type\":\"chore\",\"section\":\"Miscellaneous\",\"hidden\":false},{ \"type\": \"revert\", \"section\": \"Reverts\", \"hidden\": false }]",
"target-branch": "main"
}
}
}

0 comments on commit 24389c9

Please sign in to comment.