Skip to content

Commit

Permalink
Add xumm profile for openid userinfo
Browse files Browse the repository at this point in the history
  • Loading branch information
WietseWind committed Feb 16, 2023
1 parent dba491a commit f63c127
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { XummSdkJwt } from "xumm-sdk";
import PKCE from "xumm-js-pkce";

const log = function (...args: any[]) {
if (typeof localStorage !== 'undefined') {
if (typeof localStorage !== "undefined") {
if (localStorage?.debug) {
console.log(...args)
console.log(...args);
}
}
}
};

// localStorage.debug = "xummpkce*";
// Debug.log = log.bind(console);
Expand All @@ -31,6 +31,13 @@ interface XummPkceOptions {
implicit: boolean;
}

export interface XummProfile {
slug: string;
profileUrl: string;
accountSlug: string | null;
payString: string | null;
}

export interface ResolvedFlow {
sdk: XummSdkJwt;
jwt: string;
Expand All @@ -44,6 +51,7 @@ export interface ResolvedFlow {
source: string;
kycApproved: boolean;
proSubscription: boolean;
profile?: XummProfile;
};
}

Expand Down Expand Up @@ -264,10 +272,7 @@ export class XummPkceThread extends EventEmitter {
JSON.stringify({ jwt: resp.access_token, me })
);
} catch (e) {
log(
"Could not persist JWT to local storage",
e
);
log("Could not persist JWT to local storage", e);
}
}

Expand Down Expand Up @@ -308,10 +313,7 @@ export class XummPkceThread extends EventEmitter {
}
}, 750);
} else {
log(
"Unexpected message, skipping",
postMessage?.source
);
log("Unexpected message, skipping", postMessage?.source);
}
} catch (e) {
log("Error parsing message", (e as Error)?.message || e);
Expand Down

0 comments on commit f63c127

Please sign in to comment.