Skip to content

Commit

Permalink
feat(web): refactored the build interface
Browse files Browse the repository at this point in the history
removed the async. its not necessary and game devs will need to upgrade anyways so want to get this
in before they upgrade
  • Loading branch information
foundrium committed Dec 3, 2021
1 parent b44bb58 commit ddce4ea
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ The web SDK works by utilizing a SSO system with Haste Arcade. The SDK is a wrap
Similar to the server side SDK, `@hastearcade/web` starts by initializing a Haste object. In this case, the name of the object is `HasteClient` and the object should be maintained via an abstraction so it only need to be initialized one time.
```typescript
const hasteClient = await HasteClient.build(process.env.HASTE_GAME_CLIENT_ID);
const hasteClient = HasteClient.build(process.env.HASTE_GAME_CLIENT_ID);
```
The client id used here can be found in the developer portal and will be for your game _not your server_. See image below for a reference point:
Expand Down
2 changes: 1 addition & 1 deletion examples/authentication/single-page-app/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function App() {
// Note the first parameter should be changed to your client ID found
// in the developer portal when you created your game. Typically this can
// and should be stored as a build environment variable.
const hasteClient = await HasteClient.build('xWs8boQ2LZ4HnM1xNlt4EqfvXTdSl7io', 'auth.dev.hastearcade.com');
const hasteClient = HasteClient.build('xWs8boQ2LZ4HnM1xNlt4EqfvXTdSl7io', 'auth.dev.hastearcade.com');
setHasteClient(hasteClient);
};

Expand Down
6 changes: 1 addition & 5 deletions packages/haste-game-client/src/scenes/bootScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ export class BootScene extends Phaser.Scene {
}

async init(): Promise<void> {
this.hasteClient = await HasteClient.build(
process.env.HASTE_GAME_CLIENT_ID,
process.env.AUTH_URL,
process.env.LOGIN_URL,
);
this.hasteClient = HasteClient.build(process.env.HASTE_GAME_CLIENT_ID, process.env.AUTH_URL, process.env.LOGIN_URL);
const details = await this.hasteClient.getTokenDetails();
await this.handleLoggedInUser(details);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The web SDK works by utilizing a SSO system with Haste Arcade. The SDK is a wrap
Similar to the server side SDK, `@hastearcade/web` starts by initializing a Haste object. In this case, the name of the object is `HasteClient` and the object should be maintained via an abstraction so it only need to be initialized one time.

```typescript
const hasteClient = await HasteClient.build(process.env.HASTE_GAME_CLIENT_ID);
const hasteClient = HasteClient.build(process.env.HASTE_GAME_CLIENT_ID);
```

The client id used here can be found in the developer portal and will be for your game _not your server_. See image below for a reference point:
Expand Down
11 changes: 1 addition & 10 deletions packages/web/src/api/hasteClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class HasteClient {
this.auth0Client = auth0Client;
}

public static async build(
public static build(
clientId: string,
domain = 'auth.hastearcade.com',
signinUrl = 'https://authclient.hastearcade.com/signin',
Expand All @@ -40,15 +40,6 @@ export class HasteClient {
useCookiesForTransactions: true,
});

// this is a short term hack to avoid changing the interface last minute
// this will be removed in the next minor version release
// TODO
const sleep = (ms: number) => {
return new Promise((resolve) => setTimeout(resolve, ms));
};

await sleep(1);

return new HasteClient(
{
domain: domain,
Expand Down

0 comments on commit ddce4ea

Please sign in to comment.